Created
January 19, 2017 09:26
-
-
Save kepsic/9e19e7759e0967b44644c4b1b976af09 to your computer and use it in GitHub Desktop.
This will fix missing currency from given HansaWorld input file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import os | |
__author__ = "Andres Kepler" | |
__copyright__ = "Copyright 2017,0XFF" | |
__license__ = "GPL" | |
__version__ = "0.1" | |
__email__ = "andres@kepler.ee" | |
#Usage: Export from integration module base regster desired invoice | |
#./hw_invoice_fix.py 1703403.TXT | |
#This will output 1703403.TXT_fix.txt file | |
#Next import from base module fixed file. This will overwrite invoice | |
if len(sys.argv) < 2: | |
sys.exit('Usage: %s txt filename' % sys.argv[0]) | |
if not os.path.exists(sys.argv[1]): | |
sys.exit('ERROR: txt file %s was not found!' % sys.argv[1]) | |
with open(sys.argv[1]+'_fix'+'.txt','wb') as output: | |
with open(sys.argv[1]) as input: | |
lc=0 | |
lines = input.readlines()[0].split('\r') | |
for line in lines: | |
if lc==1: | |
newline="1\t44\t1\t1\r" | |
output.write(newline) | |
elif lc==12: | |
newline=line.split('\t') | |
if newline[33]!='EUR': | |
newline[33] = 'EUR' | |
print("FIX") | |
output.write('\t'.join(newline)+"\r") | |
else: | |
print("Not found") | |
output.write(line+"\r") | |
else: | |
output.write(line+"\r") | |
lc+=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment