import csv with open(..., 'wb') as myfile: wr = csv.writer(myfile, quoting=csv.QUOTE_ALL) wr.writerow(mylist)
Edit: this only works with python 2.x.
To make it work with python 3.x replace wb
with w
(see this SO answer)
with open(..., 'w', newline='') as myfile: wr = csv.writer(myfile, quoting=csv.QUOTE_ALL) wr.writerow(mylist)
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
- Python Error io.UnsupportedOperation: not readable
- 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?
- xlrd.biffh.XLRDError: Excel xlsx file; not supported
- Difference between writerow() and writerows() methods of Python csv module
- 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?
- Find the current directory and file’s directory [duplicate]
- Finding the index of an item in a list
- What does the list() function do in Python?
- raw_input function in Python
- How to execute a program or call a system command?
- Adding new column to existing DataFrame in Python pandas
- matplotlib error – no module named tkinter
- AttributeError: module ‘urllib3’ has no attribute ‘urlopen’ in python
- How to download a file over HTTP?
- filedialog, tkinter and opening files
- How do I get the row count of a Pandas DataFrame?
- Singular matrix issue with Numpy
- TypeError: ‘dict’ object is not callable
- Error in Python script “Expected 2D array, got 1D array instead:”?
- Get list from pandas dataframe column or row?
- ImportError: No module named ‘encodings’
- how does \r (carriage return) work in Python
- How to prompt for user input and read command-line arguments
- What is Python buffer type for?
- Empty set literal?
- How can I check file size in Python?
- Any way to clear python’s IDLE window?
- Shuffle DataFrame rows
- Checking if a number is prime in Python
- Implementing an efficient queue in Python
- Modify the legend of pandas bar plot
- Python int to binary string?
- Full examples of using pySerial package
- Checking whether a variable is an integer or not
- Using headers with the Python requests library’s get method
- How to measure elapsed time in Python?
- Issues using Keras np_utils.to_categorical
- Flask ImportError: No Module Named Flask
- Convert date to datetime in Python
- UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xa0′ in position 20: ordinal not in range(128)
- How to install PyQt5 on Windows?
- How do I get the day of week given a date?
- TypeError: ‘dict_keys’ object does not support indexing
- Add Variables to Tuple
- What does socket binding mean?
- scrapy run spider from script
- Using replace() method in python by index
- Python, how to handle the “ValueError: unsupported pickle protocol: 4” error?
- python error: TypeError: an integer is required
- Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
- Get an attribute value based on the name attribute with BeautifulSoup
- getting ValueError : “Can only tuple-index with a MultiIndex “
- ModuleNotFoundError: No module named ‘seaborn’ in Python IDE
- UnicodeEncodeError: ‘charmap’ codec can’t encode characters
- Is there a ceiling equivalent of // operator in Python?
- How to change legend size with matplotlib.pyplot
- An equivalent function to matplotlib.mlab.bivariate_normal
- Float must be a string or a number?
- Play audio with Python
- Inheritance and init method in Python
- Releasing memory in Python
- Text progress bar in terminal with block characters
- Generator expression must be parenthesized if not sole argument
- Get a Try statement to loop around until correct value obtained
- Does python have header files like C/C++?
- Making a POST call instead of GET using urllib2
- Python: OSError: [Errno 2] No such file or directory: ”
- bound method Response.json of Response [200]