in Education by
I'm working on this script that first takes all .csv's and converts them .xlsx's in a separate folder. I'm getting the first file to output exactly how I want in the 'Script files' folder, but then it throws a Traceback error before it does the second one. Script code below, Traceback error below that. Some path data removed for privacy: import pandas as pd import matplotlib.pyplot as plt import os # Assign current directory and list files there f_path = os.path.dirname(__file__) rd_path = f_path+'\\Raw Data' sc_path = f_path+'\\Script files' # Create /Script files folder if os.path.isdir(sc_path) == False: os.mkdir(sc_path) print("\nCreating new Script files path here...",sc_path) else: print("\nScript files directory exists!") # List files in Raw Data directory print("\nRaw Data files in the directory:\n",rd_path,"\n") for filename in os.listdir(rd_path): f = os.path.join(rd_path,filename) if os.path.isfile(f): print(filename) print("\n\n\n") # Copy and edit data files to /Script files folder for filename in os.listdir(rd_path): src = os.path.join(rd_path,filename) if os.path.isfile(src): name = os.path.splitext(filename)[0] read_file = pd.read_csv(src) result = sc_path+"\\"+name+'.xlsx' read_file.to_excel(result) print(src,"\nconverted and written to: \n",result,"\n\n") Traceback (most recent call last): File "C:\Users\_________________\Graph.py", line 32, in read_file = pd.read_csv(src) File "C:\Users\_____________\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper return func(*args, **kwargs) File "C:\Users\______________\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\parsers\readers.py", line 680, in read_csv return _read(filepath_or_buffer, kwds) File "C:\Users\_____________\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\parsers\readers.py", line 581, in _read return parser.read(nrows) File "C:\Users\_____________\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\parsers\readers.py", line 1250, in read index, columns, col_dict = self._engine.read(nrows) File "C:\Users\_____________\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 225, in read chunks = self._reader.read_low_memory(nrows) File "pandas\_libs\parsers.pyx", line 805, in pandas._libs.parsers.TextReader.read_low_memory File "pandas\_libs\parsers.pyx", line 861, in pandas._libs.parsers.TextReader._read_rows File "pandas\_libs\parsers.pyx", line 847, in pandas._libs.parsers.TextReader._tokenize_rows File "pandas\_libs\parsers.pyx", line 1960, in pandas._libs.parsers.raise_parser_error pandas.errors.ParserError: Error tokenizing data. C error: Expected 2 fields in line 47, saw 8 JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Have you tried to convert to xlsx the second file in the folder? I'm not sure but it seems like there's a problem when Pandas reads the csv.

Related questions

0 votes
    I'm working on this script that first takes all .csv's and converts them .xlsx's in a separate ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    I have a dataframe as below itm Date Amount 67 420 2012-09-30 00:00:00 65211 68 421 2012-09-09 00 ... solutions would be appreciated. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    What kind of files can be imported or exported using the COPY command (1)sstables (2)CSV (3)json (4)parquet...
asked Apr 17, 2021 in Technology by JackTerrance
0 votes
    I have the following df | 1 | 2 | 3 | ------------------------- 0.11 ... JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    when i want to execute below code and plot figer scatter_matrix(total_frame) total_frame is a dataframe like ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    An irregular time series data is stored in a pandas.DataFrame. A DatetimeIndex has been set. I need the ... seemingly simple operation? Select the correct answer from above options...
asked Feb 3, 2022 in Education by JackTerrance
0 votes
    Working with census data, I want to replace NaNs in two columns ("workclass" and "native-country") with the ... way to do this? Select the correct answer from above options...
asked Feb 3, 2022 in Education by JackTerrance
0 votes
    I am trying to groupby a column and compute value counts on another column. import pandas as pd dftest = pd. ... Amt, already exists Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I'm starting with input data like this df1 = pandas.DataFrame( { "Name" : ["Alice", "Bob", "Mallory", ... Any hints would be welcome. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I have a 20 x 4000 dataframe in python using pandas. Two of these columns are named Year and quarter. I'd ... anyone help with that? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I'm trying to get the number of rows of dataframe df with Pandas, and here is my code. Method 1: total_rows ... What am I doing wrong? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    How do I get the index column name in python pandas? Here's an example dataframe: Index Title Column 1 Apples 1 ... how to do this? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I have a dataset |category| cat a cat b cat a I'd like to be able to return something like (showing unique values ... cat a 2 cat b 1 Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I have a pandas data frame like: a b A 1 A 2 B 5 B 5 B 4 C 6 I want to group by the ... do something like this using pandas groupby? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I want to get a list of the column headers from a pandas DataFrame. The DataFrame will come from user input so I don ... 'gdp', 'cap'] Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
...