Questions tagged [read-csv]

22 questions
1
vote
2 answers

Read .txt file in python, assign first line to a variable and from 2nd line to a dataframe

Working on Python script to read .txt files(space seperated) to a pandas dataframe. But 1st line contain server information. How do I extract 1st line to other variable and remaining file content to a pandas dataframe? Sample file1.txt srv123 …
Kavya shree
  • 312
  • 1
  • 7
  • 24
1
vote
2 answers

Gathering multiple text files containing multiple tables to a Pandas dataframe

I'm trying to gather multiple csv files from one folder into a dataframe. With this prior question we realized the real issue is that some csv files (summary files) contain more than one table. As a result, the current solution's product (code…
natural_d
  • 15
  • 5
1
vote
2 answers

Java - search csvfile using arrays

I have a csv.file with 80 lines and 4 columns that represents one specific Movie Store. 1st column: idSale 2nd column: Movie 3rd column: Genre 4td column: Director The file has a header with the names above and the rest of lines are the…
DR8
  • 127
  • 5
1
vote
0 answers

How to solve the KeyError: "None of [Index([....]) are in the [columns]"

Here is my code, it may error and stop when running. Not always, maybe I get an error on the hundredth run. I do not understand what is the reason. I know that there is a problem when reading the csv file. Desired result: I want to be able to at…
Tornike k
  • 21
  • 3
1
vote
3 answers

How to use Python Polars read_csv when column length increases after row 1?

I have an example CSV with 1 column in row 1 and 2 columns in the other rows. The parser in Polars read_csv only recognizes 1 column. How do I force it to read more columns? I cannot simply use skiprows because sometimes more than the first row is a…
Josh Y.
  • 11
  • 2
1
vote
1 answer

Unreadable test with list of encoding in pandas

I am trying to read in this dataset path = "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1165013/UK_Sanctions_List.ods" By using this code (I have seen there are quite a lot of threads/suggested…
Giampaolo Levorato
  • 1,055
  • 1
  • 8
  • 22
0
votes
1 answer

read csv file to rename and move to new (variable) path

I have hundreds of files in subdirectories that need to be renamed and then moved to a new location specified in a csv column (the path depends on the ID and reference ID). I need to rename the files in their original location first since some may…
MzNix
  • 1
  • 2
0
votes
2 answers

Error tokenizing data. C error: Expected 5 fields in line 37, saw 6

I want to make a dataframe of this txt file. I tried changing delimiters or using multiple seperators or quoting csv.QUOTE_NONE, but can't read this file. please help. df = pd.read_csv('../sort.txt', delimiter=',', header=None,…
0
votes
1 answer

Python Pandas read_csv in strange format

Is it possible to read_csv a file that has a double quote as a value and fields are wrapped in double quotes to ignore commas as values? An example file looks like this: "fie,ld1","fi"e,ld2","field3" "test","testing","meow" Desired output is…
matixsnow
  • 69
  • 4
0
votes
1 answer

How to get the custom separator Excel uses in pd.read_csv()

I have several .txt files with data I would like to plot. Since there are so many, I prefer using python to plot these rather than Excel. The .txt files have been generated by German machinery, which is the reason for a decimal comma. This can be…
0
votes
0 answers

Unable to read csv file in Jupyter notebook from my PC local folder

I tried reading a csv file from a local source on my pc but it was displaying the following: sales = pd.read_csv('C:/Users/Admin/Documents/survey_results_public.csv') NameError Traceback (most recent call last) Cell…
0
votes
0 answers

how do I change the data type in each cell in a column when I read it using the read_csv function in the pandas library python?

when I run the code to change the data type of the value in each cell in a column while reading the csv file with the pandas library read_csv() function an error occurs. The following is the error message on the ipython console: Traceback (most…
asrl94
  • 1
  • 1
0
votes
0 answers

Stored procedure not able to read csv file through filepath via LOAD_FILE()

I want to create a stored procedure in mySQL workbench which reads a csv file from a path. I have made all required changes in my.ini file, set file path, secure_file_priv = "my/file/path", username is having 'file permission'. folder in which I…
0
votes
0 answers

Pandas dataframe is broken up in groups of columns

I have a CSV file that I need to display on a Tkinter text box. I have everything I need inserted into the text box; however it is broken up similar to how it is displayed in the terminal after printing. Here is what is being displayed in the text…
Devin Bowen
  • 127
  • 1
  • 1
  • 13
0
votes
0 answers

Getting an error in vroom file when I try to read in a CSV file

I am getting a weird error message when I try to read my csv file into R. For some reason it is only when I try to read in this specific csv file that I get this error, otherwise my code works for other csv files. I tried to do the read_csv function…
zwyn
  • 1
1
2