Skip to content

Commit ae7a11f

Browse files
committed
convert all xls to csv files
1 parent 4e78f06 commit ae7a11f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

analysis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from clustering import CHalos

xls_to_csv.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import subprocess
2+
import os
3+
import argparse
4+
5+
6+
def convert(filename, output_dir):
7+
cmd = ["libreoffice", "--headless", "--convert-to", "csv"] + [filename] + ["--outdir"] + [output_dir]
8+
subprocess.Popen(cmd)
9+
10+
11+
def convertFolder(foldername):
12+
for root, dirs, files in os.walk(foldername):
13+
for filename in files:
14+
if filename.endswith(".xls"):
15+
convert(os.path.join(root, filename), root)
16+
17+
18+
if __name__ == "__main__":
19+
parser = argparse.ArgumentParser(description="convert all xls files to csv")
20+
parser.add_argument("foldername")
21+
22+
args = parser.parse_args()
23+
24+
convertFolder(args.foldername)

0 commit comments

Comments
 (0)