2021年3月18日星期四

Read comma separated csv file with fields containing commas using fread in r

I have a csv file separated by comma. However, there are fields containing commas like company names "Apple, Inc" and the fields will be separated into two columns, which leads to the following error using fread.

"Stopped early on line 5. Expected 26 fields but found 27."

Any suggestions on how to appropriately load this file? Thanks in advance!

Add:

Example rows are as follows. It seems that there are some fields with comma without quotes. But they have whitespace following the comma inside the field.

100,Microsoft,azure.com  300,IBM,ibm.com  500,Google,google.com  100,Amazon, Inc,amazon.com  400,"SAP, Inc",sap.com  
https://stackoverflow.com/questions/66700634/read-comma-separated-csv-file-with-fields-containing-commas-using-fread-in-r March 19, 2021 at 07:41AM

没有评论:

发表评论