Our Thinking

This is a forum to share our thoughts and get your feedback.

  • Home
    Home This is where you can find all the blog posts throughout the site.
  • Categories
    Categories Displays a list of categories from this blog.
  • Tags
    Tags Displays a list of tags that have been used in the blog.
  • Bloggers
    Bloggers Search for your favorite blogger from this site.
  • Team Blogs
    Team Blogs Find your favorite team blogs here.
  • Login
    Login Login form

Python Rest Services on CSV Data

Posted by on in Python Rocks!
  • Font size: Larger Smaller
  • Hits: 1024
  • 0 Comments
  • Subscribe to this entry
  • Print

 Web service dependencies are very common in client server application development. In many cases client application development may get completed before server, in such case client application cannot be tested fully as real services and data is not ready.

 Many tools are available to mock web services but they are not QA friendly, QA can’t pass different data sets easily to the mock services.

 So, here I have written a simple python script which exposes data of a csv file as a JSON via simple http rest services. These services can be consumed by client applications and QA to simulate real services and data. 

I have basic employee data in a csv file, here are the list of services which exposes data via python.

  • CSV Data
    • b2ap3_thumbnail_Picture1.png
  • Services
    1. /emp - return all rows of the csv file as a JSON array.
    2. /emp/column/{csv column name} – It return all values of a csv column.
      • g. - /emp/column/City will return all Cities like “Seattle, Fairfax, ALDIE, Chantilly, Herndon”
    3. /emp/search/{search string} - It returns all rows of the csv file in a json array, where each row contains given string.
    4. /emp/search/{csv column name}/{searchString} – It works same like above service but the search is performed only in the given column name instead of on all columns.
  • Sample response format
    • b2ap3_thumbnail_Picture2.png

The python script and employee data csv file are attached here. The script can be extended for multiple services for different need. I have used these services primarily to consume data in salesforce environment based on different search criteria.

Python Script and CSV file

0

Comments

  • No comments made yet. Be the first to submit a comment

Leave your comment

Guest
Guest Friday, 14 December 2018

Archive

January
February
March
May
July
August
September
October
November
December
January
February
March
June
August
September
November
December
January
March
April
May
June
August
October
November
December
January
February
March
April
May
June
July
November
December
Go to top