Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Write a table to CSV file python

header = [re.sub(' +',' ',i[0][:-1].replace('
', ' ')) for i in optionsTable[0]]

with open('test.csv', 'w') as fp:
   writer = csv.writer(fp, delimiter=',')
   writer.writerow(header)
   for row in optionsTable:
      writer.writerow([i[1] for i in row])

#Credit to https://stackoverflow.com/users/790387/burhan-khalid Burhan Khalid
#On StackOverflow.
Comment

PREVIOUS NEXT
Code Example
Python :: python discord 
Python :: graph a line from dataframe values over a bar plot in python 
Python :: modify a list with for loop and range function in python 
Python :: pivot pyspark 
Python :: set environment variable flask app 
Python :: python extract string 
Python :: python mathematics 
Python :: PY | websocket - server 
Python :: how to make a python terminal 
Python :: password guessing game python 
Python :: Format UTC to local timezone using PYTZ for Django 
Python :: how to access variables from a class in python 
Python :: run python script from repl 
Python :: IndentationError: unexpected indent 
Python :: find element in list that matches a condition 
Python :: z score formula in pandas 
Python :: pandas count 
Python :: str replace pandas 
Python :: python if type dict 
Python :: pretty printing using rich library in python 
Python :: django sample 
Python :: fillna not work 
Python :: ram clear in python 
Python :: Set value for particular cell in pandas DataFrame using index 
Python :: discord.py clear status 
Python :: line plot python only years datetime index 
Python :: dataframe subtract value from previous row 
Python :: pandas difference between rows in a column 
Python :: python comparison operators 
Python :: how to download from url in python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =