Code from Xls file downloaded to json file sent

Hello,

I am wondering what is the exact code to transform the .CSV file provided by Kobo into the json file provided by kobo.

The .CSV file is what I download from the project page.
The Json file is what we get from the API and send to our ETL.

Any opinion on the code ? My goal is to manually transform some .csv file into the json file to send back some updated data to our ETL ?

thanks a lot :slight_smile:

@it_maxence_delaunay, why not try this approach of uploading the data to the server by using POSTMAN as outlined in this post discussed previously:

Certainly! To transform a .CSV file into a JSON file, you can use a programming language like Python. Below is a simple example of how you can achieve this using the pandas library:
Install pandas if you havenā€™t already: KMFusa
pip install pandas
Python code to convert .CSV to JSON:
import pandas as pd

Load the CSV file into a DataFrame

df = pd.read_csv(ā€˜yourfile.csvā€™)

Convert the DataFrame to a JSON string

json_str = df.to_json(orient=ā€˜recordsā€™)

Save the JSON string to a file

with open(ā€˜output.jsonā€™, ā€˜wā€™) as json_file:
json_file.write(json_str)

print(ā€œCSV file has been converted to JSON and saved as ā€˜output.jsonā€™ā€)

In this example:

  • Replace 'yourfile.csv' with the path to your CSV file.
  • The orient='records' parameter converts the DataFrame to a JSON array of records (dictionaries).

This code will help you manually transform your CSV file into a JSON file to send back updated data to your ETL process.