0

I have read a file in google colab from my local machine.

How to use "delimeter = ';' "in the following command ?

import io

df = pd.read_csv(io.StringIO(uploaded['train.csv'].decode('utf-8')))
  • may be `pd.read_csv(filepath_or_buffer= 'train.csv', sep=";")` – PKumar Mar 22 '21 at 10:20
  • please check: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html delimeter is ```sep``` argument – Artyom Akselrod Mar 22 '21 at 11:21
  • Does this answer your question? [pandas dataframe read\_csv, specify columns and keep whole line as a string](https://stackoverflow.com/questions/42134428/pandas-dataframe-read-csv-specify-columns-and-keep-whole-line-as-a-string) – M_x Mar 22 '21 at 11:46

2 Answers2

0

As previously mentioned, you can use the 'sep' or 'delimiter' argument to define which delimiter you want to use. Since you are reading it in from your local machine df = pd.read_csv('example.csv', delimiter=";") should do the trick just fine. Here is an example of how I was able to read in a similar type of file: https://gist.github.com/jwmartinez1/d773988bfd789f14431704c006858542.

tdy
  • 36,675
  • 19
  • 86
  • 83
0

you can use delimiter or sep

  • sep : str

    • Delimiter to use. If sep is None, the C engine cannot automatically detect the separator, but the Python parsing engine can, meaning the latter will be used and automatically detect the separator by Python’s builtin sniffer tool, csv.Sniffer. In addition, separators longer than 1 character and different from '\s+' will be interpreted as regular expressions and will also force the use of the Python parsing engine. Note that regex delimiters are prone to ignoring quoted data. Regex example: '\r\t'.
  • delimiter : str

    • Alias for sep.

follow this link for more

M_x
  • 782
  • 1
  • 8
  • 26