简体   繁体   中英

how to convert a csv file to json in the format below on python

I would like to convert a csv to Json in the format below:

{  cols: [   {id: "DATA", label: "DATA", type: "date"},   {id: "test1", label: "test1", type: "number"},    {id: "test2", label: "test2", type: "number"},    {id: "test3", label: "test3", type: "number"},    .    .    .   ],   rows: [    {c: [      {v: new Date(2019,7,1), f: "2019-07-01"},     {v: 14111},     {v: null},     {v: null},     .     .     .    ]} }

It's possible?

Good Afternoon Aditya Singh,

So what I want is to transform a csv from the pattern below:

         DATA_CRIACAO;PROMOCAO_1067;PROMOCAO_1068 
         01/07/0019;14217; 
         01/07/0019;;24 

to Json in the format below:

 { cols: [ {id: "DATA_CRIACAO", label: "DATA_CRIACAO", type: "date"}, {id: "PROMOCAO_1067", label: "PROMOCAO_1067", type: "number"}, {id: "PROMOCAO_1068", label: "PROMOCAO_1068", type: "number"} ], rows: [ {c: [ {v: new Date(2019,7,1), f: "2019-07-01"}, {v: 14111}, {v: null} ]} {c: [ {v: new Date(2019,7,1), f: "2019-07-01"}, {v: null}, {v: 24} ]} ] }

What I wanted is to create a structure in Json in the pattern above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM