i have this error and i don’t know why i got it. I followed the steps from my Python manual and i got this. I am tryng to cleanup the file on column 8 and 9 if they have that odd character. If someone could help me, please advise.
The error appear on the line of code: for row in csv.reader(f):
Please find below my code:
import csv file = '/Users/cohen/Desktop/sdn-2.csv' newstring = "null" newinteger = int(0) with open(file, 'r+') as f: for row in csv.reader(f): if row[7] =="-0-": row[7] = newinteger if row[8] == "-0-": row[8] = newinteger f.close()
***LATER EDIT I changed the code as above, but is not doing anything is not replacing the -0-
with 0
Related Posts:
- TypeError: list indices must be integers or slices, not str
- Writing a pandas DataFrame to CSV file
- Writing a pandas DataFrame to CSV file
- IndexError: too many indices for array
- ValueError : I/O operation on closed file
- Pandas: ValueError: cannot convert float NaN to integer
- csv.Error: iterator should return strings, not bytes
- Python – Reading and writing csv files with utf-8 encoding
- load csv into 2D matrix with numpy for plotting
- Dump a NumPy array into a csv file
- (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
- How to load a tsv file into a Pandas DataFrame?
- Difference between writerow() and writerows() methods of Python csv module
- Create a .csv file with values from a Python list
- Convert XML to CSV file
- TypeError: list indices must be integers or slices, not str
- Convert from CSV to array in Python
- ValueError: cannot index with vector containing NA / NaN values
- (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
- Creating a dictionary from a csv file?
- Python import csv to list
- ValueError: x and y must be the same size
- OSError: Initializing from file failed on csv in Pandas
- append new row to old csv file python
- Writing a dictionary to a csv file with one line for every ‘key: value’
- Python CSV error: line contains NULL byte
- Python CSV Error: sequence expected
- AttributeError: ‘float’ object has no attribute ‘split’4
- How to add pandas data to an existing csv file?
- convert csv file to list of dictionaries
- _csv.Error: field larger than field limit (131072)
- CSV new-line character seen in unquoted field error
- Writing Python lists to columns in csv
- Error in Reading a csv file in pandas[CParserError: Error tokenizing data. C error: Buffer overflow caught – possible malformed input file.]
- How to read a CSV file from a URL with Python?
- How to import a csv-file into a data array?
- Remove all whitespace in a string
- What is a “method” in Python?
- How to generate all permutations of a list?
- Is there a Python equivalent to Ruby’s string interpolation?
- Python Progress Bar
- Most efficient way to find mode in numpy array
- Python error “ImportError: No module named”
- How to groupby based on two columns in pandas?
- How do I append one string to another in Python?
- Python Progress Bar
- How to correct TypeError: Unicode-objects must be encoded before hashing?
- Python: list of lists
- How can I split and parse a string in Python?
- numpy matrix vector multiplication
- whitespace in regular expression
- proper name for python * operator?
- How to do superscripts and subscripts in Jupyter Notebook?
- How do I unload (reload) a Python module?
- ImportError: No module named PIL
- Maximum and Minimum values for ints
- How do I list all files of a directory?
- How to check whether a str(variable) is empty or not?
- Add list to set?
- Infinite integer in Python
- Determine Whether Integer Is Between Two Other Integers?
- If vs. else if vs. else statements?
- Quoting backslashes in Python string literals
- AttributeError: Can only use .dt accessor with datetimelike values
- Python string class like StringBuilder in C#?
- How do I clear all variables in the middle of a Python script?
- How to tell if tensorflow is using gpu acceleration from inside python shell?
- What is the easiest way to get current GMT time in Unix timestamp format?
- xlrd.biffh.XLRDError: Excel xlsx file; not supported
- Python/Json:Expecting property name enclosed in double quotes
- Normalize columns of pandas data frame
- Python Error: “ValueError: need more than 1 value to unpack”
- Python: can’t assign to literal
- “Initializing” variables in python?
- Difference between except: and except Exception as e:
- Flask raises TemplateNotFound error even though template file exists
- Python: Declare as integer and character
- Python socket.error: [Errno 111] Connection refused
- Windows- Pyinstaller Error “failed to execute script ” When App Clicked
- Python: What is the correct MIME type for attaching html file to email
- Linear regression with matplotlib / numpy
- Solving “500: Internal Server Error, nbconvert failed: xelatex not found in PATH”
- Using Look Up Tables in Python
- Parallel Python: What is a callback?
- python NameError: name ‘file’ is not defined
- python BeautifulSoup parsing table
- Python Add to dictionary loop
- how to exit a python script in an if statement
- How to add column to numpy array
- OpenCV NoneType object has no attribute shape
- AttributeError: ‘str’ object has no attribute ‘items’
- ImportError: No module named Crypto.Cipher
- TypeError: ‘range’ object does not support item assignment
- Convert string to variable name in python
- Can not click on a Element: ElementClickInterceptedException in Splinter / Selenium
- How to split elements of a list?
- Syntax highlighting in vim for python
- Python IOError: File not open for reading
- Strange Exception in Tkinter callback
- How to resolve “ImportError: DLL load failed:” on Python?