renaming csv tsv
This commit is contained in:
16
tsvedit.py
16
tsvedit.py
@@ -214,18 +214,18 @@ if not which('sc'):
|
||||
|
||||
opts=setup_options()
|
||||
|
||||
f_split=os.path.split(opts.csv)
|
||||
f_split=os.path.split(opts.tsv)
|
||||
f_bkp=os.path.join(f_split[0],'_bkp.'+f_split[1])
|
||||
f_sc=opts.csv+'.sc'
|
||||
f_sc_tmp=opts.csv+'.sc.tmp'
|
||||
f_sc=opts.tsv+'.sc'
|
||||
f_sc_tmp=opts.tsv+'.sc.tmp'
|
||||
|
||||
# copy a backup file
|
||||
if opts.backup and os.path.exists(opts.csv):
|
||||
shutil.copyfile(opts.csv, f_bkp)
|
||||
if opts.backup and os.path.exists(opts.tsv):
|
||||
shutil.copyfile(opts.tsv, f_bkp)
|
||||
|
||||
# create new empty file if not exist
|
||||
if not os.path.exists(opts.csv):
|
||||
open(opts.csv,'w').close()
|
||||
if not os.path.exists(opts.tsv):
|
||||
open(opts.tsv,'w').close()
|
||||
|
||||
# Convert CSV -> SC
|
||||
f_sc_w=open(f_sc,'wt')
|
||||
@@ -255,7 +255,7 @@ f_cs_tmp_w.close()
|
||||
|
||||
# Convert SC -> CSV
|
||||
f_sc_r=open(f_sc_tmp,'rt')
|
||||
f_csv_w=open(opts.csv,'wt')
|
||||
f_csv_w=open(opts.tsv,'wt')
|
||||
sc_reader=SCReader(f_sc_r)
|
||||
csv_write(sc_reader,f_csv_w)
|
||||
f_sc_r.close()
|
||||
|
||||
Reference in New Issue
Block a user