Table of Contents generated with DocToc
This repo contains code to merge two *.csv files : daily.csv
& companies.csv
Submit a new file merge request.
-
daily.csv
filecompanies.csv
filestart_date
string MM/DD/YY (eg. 03/11/16)end_date
string MM/DD/YY (eg. 03/15/16)n
integer Skip Interval (>0)
-
- Success:
- Response Code : 200
- Headers:
- Content-Type:
text/csv
- Id: integer : request_id
- Content-Disposition:
attachment; filename=merged_file.csv
- Content-Type:
- Error :
- Response Code : 500
- Success:
Retrieve past file merge record by ID from database.
-
-
- Response Code : 200
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
- Sample Response :
{ "companies": [['C1', 'Company 1'], ['C1', 'Company 2']], "created_at": "2017-05-13 00:50:06.158587", "daily_vals": [['C1', '1/1/17', '32'], ['C2', '1/1/17', '3']], "end_date": "1/1/17", "n": 1, "sender_ip": "127.0.0.1", "start_date": "12/31/16" }
- Sample Response :
-
- Response Code : 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body :
- Sample Response :
{"message": "Request ID : <int> not found"}
- Sample Response :
-
Delete record from database.
-
-
- Response Code : 200
- Headers:
- Content-Type:
application/json
- Content-Type:
-
- Response Code : 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body :
- Sample Response :
{"message": "Request ID : <int> not found"}
- Sample Response :
-
-
Set required permissions to the setup script
chmod +x setup.sh
-
Run the setup script
sudo -H ./setup.sh <port-no>
This will launch an instance of the web application listening on the specified port-no. -
Make API Calls to the end-points
- Merge CSV file
curl -i -X POST \ http://<ip>:<port>/csvmerge/api/1.0.0/files \ -H 'content-type: multipart/form-data \ -F daily.csv=@<path-to-daily.csv> \ -F companies.csv=@<path-to-companies.csv> \ -F start_date=12/31/16 \ -F end_date=1/11/17 \ -F n=1
- Retrieve Record by ID
curl -X POST \ http://<ip>:<port>/csvmerge/api/1.0.0/files/<request-id>
- Delete Record
curl -X DELETE http://<ip>:<port>/csvmerge/api/1.0.0/files/<request-id>
Commited