I have two files, file_1.csv has several lines, each line contains several numbers, like:
1,2,3
4,5,6
7
8,9
...
while file_2.csv counts the number of numbers per line in file_1, like:
3
3
0
0
1
2
...
I want use the data with MongoDB, so I am reformulating the data from csv to json. The json file should have three key-value pairs. First key shows the line index. Second key includes the numbers from file_1. Key three includes data from file_2, like this:
{
“id”: 1,
"numbers": [1,2,3],
"count": 3
}
...
Of course I can do it by with open()..
to read them to arrays, and then formulate the data in a json format, but I am wondering if there is any other way to do it faster, since my data is quite large? Besides, I am not very sure how can I formulate integer array to json value in python?
Many many thanks!