csv

CSV to Nested JSON C#

荒凉一梦 提交于 2020-06-01 05:59:05
问题 I would like to convert a csv file into json with nested objects and nested array. The sample csv looks like below. My csv structure can be dynamic, but I am ok to keep it static to get the required format below. I know there are so many answers to similar questions, but none addressing my specific issue of nested objects. Id,name,nestedobject/id,nestedarray/0/name 1,name,2,namelist 2,name1,3,namelist1 I want the json like below, specifically having trouble with column 3 & 4 (nested objects)

Converting a JSON with a nested array to CSV

倾然丶 夕夏残阳落幕 提交于 2020-06-01 03:32:10
问题 Here is a template of my JSON: { "field 1": [ { "id": "123456" }, { "about": "YESH" }, { "can_post": true }, { "category": "Community" } ], "field 2": [ { "id": "123456" }, { "about": "YESH" }, { "can_post": true }, { "category": "Community" } ] } I would like to convert this JSON into a csv in the following format using Python: 0 field 1, id, about, can_post, category 1 field 2, id, about, can_post, category I tried using pandas to read_json and then to_csv but it didn't work. Thanks 回答1:

Read multiple csv files into separate dataframes using pandas

感情迁移 提交于 2020-05-30 17:38:59
问题 I like to read two csv files from a particular folder into two separate dataframes. The two file names are: 23314621_MACI_NAV.CSV and 23314623_MACI_Holding.CSV The file second part of the file names are fixed MACI_NAV.CSV and MACI_Holding.CSV, however the first part of the file name which are numbers change everyday. I like to read them into two different dataframe by trying this: import pandas as pd import glob msci_folder = 'N:/Operation/Daily CDS E_Report/CDS/MACI/' mscifile = glob.glob

Read multiple csv files into separate dataframes using pandas

拟墨画扇 提交于 2020-05-30 17:34:22
问题 I like to read two csv files from a particular folder into two separate dataframes. The two file names are: 23314621_MACI_NAV.CSV and 23314623_MACI_Holding.CSV The file second part of the file names are fixed MACI_NAV.CSV and MACI_Holding.CSV, however the first part of the file name which are numbers change everyday. I like to read them into two different dataframe by trying this: import pandas as pd import glob msci_folder = 'N:/Operation/Daily CDS E_Report/CDS/MACI/' mscifile = glob.glob

How to filter a very large csv in R prior to opening it?

北城以北 提交于 2020-05-30 10:48:19
问题 I'm currently trying to open a 48GB csv on my computer. Needless to say that my RAM does no support such a huge file, so I'm trying to filter it before opening. From what I've researched, the most appropriate way to do so in R is using the sqldf lib, more specifically the read.csv.sql function: df <- read.csv.sql('CIF_FOB_ITIC-en.csv', sql = "SELECT * FROM file WHERE 'Year' IN (2014, 2015, 2016, 2017, 2018)") However, I got the following message: Erro: duplicate column name: Measure As SQL is

Import CSV data into Google Sheets

两盒软妹~` 提交于 2020-05-30 08:13:10
问题 When trying to use the IMPORTDATA function for this file: https://www.kaggle.com/stefanoleone992/fifa-20-complete-player-dataset#players_20.csv An unexpected error occurs that says it is impossible to import data into the spreadsheet. Is there any other way that I can bring this data to my spreadsheet? This data would be very important to the work I'm doing. It would save me from almost 3 months of work to be able to type and copy everything and then filtering according to my need. It would

Using PapaParse transformHeader to remove whitespace from headers?

99封情书 提交于 2020-05-30 07:53:51
问题 If we have a CSV file like this: `firstName, lastName Jim, Carrey Stephen, Colbert` Papaparse will output the dynamically typed result like this: {firstName: 'Jim', ' lastName': '30000'} In order to just get {firstName: 'Jim', lastName...} PapaParse 5.0.0 has a transformHeaders option, but there's no documentation on how to achieve this result yet. Anyone have a transformHeader snippet that does this? 回答1: This ended up doing the trick: const config = { delimiter: ",", header: true,

Using PapaParse transformHeader to remove whitespace from headers?

谁都会走 提交于 2020-05-30 07:53:16
问题 If we have a CSV file like this: `firstName, lastName Jim, Carrey Stephen, Colbert` Papaparse will output the dynamically typed result like this: {firstName: 'Jim', ' lastName': '30000'} In order to just get {firstName: 'Jim', lastName...} PapaParse 5.0.0 has a transformHeaders option, but there's no documentation on how to achieve this result yet. Anyone have a transformHeader snippet that does this? 回答1: This ended up doing the trick: const config = { delimiter: ",", header: true,

How to add new column with header to csv with awk

别说谁变了你拦得住时间么 提交于 2020-05-29 04:59:12
问题 I'm using some awk inside a bash script that's handling CSVs. The awk does this: ORIG_FILE="score_model.csv" NEW_FILE="updates/score_model.csv" awk -v d="2017_01" -F"," 'BEGIN {OFS = ","} {$(NF+1)=d; print}' $ORIG_FILE > $NEW_FILE Which does this transformation: # before model_description, type, effective_date, end_date Inc <= 40K, Retired, 08/05/2016, 07/31/2017 Inc > 40K Age <= 55 V5, Retired, 04/30/2016, 07/31/2017 Inc > 40K Age > 55 V5 , Retired, 04/30/2016, 07/31/2017 # after, bad model

How to add new column with header to csv with awk

为君一笑 提交于 2020-05-29 04:59:05
问题 I'm using some awk inside a bash script that's handling CSVs. The awk does this: ORIG_FILE="score_model.csv" NEW_FILE="updates/score_model.csv" awk -v d="2017_01" -F"," 'BEGIN {OFS = ","} {$(NF+1)=d; print}' $ORIG_FILE > $NEW_FILE Which does this transformation: # before model_description, type, effective_date, end_date Inc <= 40K, Retired, 08/05/2016, 07/31/2017 Inc > 40K Age <= 55 V5, Retired, 04/30/2016, 07/31/2017 Inc > 40K Age > 55 V5 , Retired, 04/30/2016, 07/31/2017 # after, bad model