Download JSON data via API
Budget: ₹1,500 – ₹12,500 INR
Need a C#.NET Winforms application developed that will obtain JSON data and download it to MS Excel. Create separate files for records over 500,000.
I need data downloaded from this website.
https://fdc.nal.usda.gov/download-datasets.html
The API to get the JSON data is here.
https://app.swaggerhub.com/apis/fdcnal/food-data_central_api/1.0.1
This is the data that is needed. (Let me know if you need me to pay for a membership on this site so you can access the data).
https://app.swaggerhub.com/apis/fdcnal/food-data_central_api/1.0.1#/BrandedFoodItem
Here is the code to parse the data and save the data as needed.
int chunkSize = 500000;
int fileNo = 1;
int totalRecords = count;
int getSize = totalRecords;
int recordsToSkip = 0;
while (totalRecords > 0)
{
string exportFile = file + "-" + fileNo.ToString() + ".xlsx";
int currentChunkSize = Math.Min(chunkSize, totalRecords);
var recordsToExport = _dt.AsEnumerable().Skip(recordsToSkip).Take(currentChunkSize).ToList();
DataTable dtExport = recordsToExport.CopyToDataTable();
_success = ExportExcel.ExportExcelData(dtExport, exportFile);
recordsToSkip += chunkSize;
totalRecords -= chunkSize;
fileNo++;
}
Lastly, Funds will be put in milestone and release after I receive the code and test it.
I need data downloaded from this website.
https://fdc.nal.usda.gov/download-datasets.html
The API to get the JSON data is here.
https://app.swaggerhub.com/apis/fdcnal/food-data_central_api/1.0.1
This is the data that is needed. (Let me know if you need me to pay for a membership on this site so you can access the data).
https://app.swaggerhub.com/apis/fdcnal/food-data_central_api/1.0.1#/BrandedFoodItem
Here is the code to parse the data and save the data as needed.
int chunkSize = 500000;
int fileNo = 1;
int totalRecords = count;
int getSize = totalRecords;
int recordsToSkip = 0;
while (totalRecords > 0)
{
string exportFile = file + "-" + fileNo.ToString() + ".xlsx";
int currentChunkSize = Math.Min(chunkSize, totalRecords);
var recordsToExport = _dt.AsEnumerable().Skip(recordsToSkip).Take(currentChunkSize).ToList();
DataTable dtExport = recordsToExport.CopyToDataTable();
_success = ExportExcel.ExportExcelData(dtExport, exportFile);
recordsToSkip += chunkSize;
totalRecords -= chunkSize;
fileNo++;
}
Lastly, Funds will be put in milestone and release after I receive the code and test it.