6 examples of 'python convert xlsx to csv' in Python

Every line of 'python convert xlsx to csv' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
13def test_xlsx(self):
14 with open('examples/test.xlsx', 'rb') as f:
15 output = xlsx.xlsx2csv(f)
16
17 with open('examples/testxlsx_converted.csv', 'r') as f:
18 self.assertEquals(f.read(), output)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

20def test_xls_with_sheet(self):
21 with open('examples/sheets.xls', 'rb') as f:
22 output = xls.xls2csv(f, sheet='data')
23
24 with open('examples/testxls_converted.csv', 'r') as f:
25 self.assertEquals(f.read(), output)
84def WriteToExcel():
85 f = open('wordbank.csv','w')
86 list = CountInstancesGlobal()
87 for twoplet in list:
88 f.write(str(twoplet[0]))
89 f.write(',')
90 f.write(str(twoplet[1]))
91 f.write('\n')
92 f.close()
8def convert(csv_path):
9 with open(csv_path) as f:
10 data = Data(f)
11
12 table = Table()
13 table.set_header(["procedure", "time [s]", "speedup", ""])
14
15 reference_time = None
16 for name, time in data:
17 if reference_time is None:
18 reference_time = time
19
20 speedup = reference_time/time
21
22 time = '%0.5f' % time
23 bar = unicode_bar(speedup * 10)
24 speedup = '%0.2f' % speedup
25 table.add_row([name, time, speedup, bar])
26
27 def get_path():
28 basename = os.path.splitext(os.path.basename(csv_path))[0]
29 return basename + ".txt"
30
31 path = get_path()
32 with open(path, 'wt', encoding='utf-8') as f:
33 f.write(unicode(table))
34
35 print "%s created" % path
42def process_sheet(sheet):
43 if "General" in sheet.name:
44 process_general(sheet)
45 else:
46 process_primary(sheet)
34def read_excel_file(f):
35 dialect = csv.Sniffer().sniff(codecs.EncodedFile(f, "utf-8").read(1024))
36 #f.open()
37 return UnicodeCsvReader(codecs.EncodedFile(f, "utf-8"),
38 "utf-8", dialect=dialect)

Related snippets