Im currently working on a script to import data from a .csv file containing financial accounting information. This .csv could contain either a number format like this: "100.000" or like this "100.000,00". Because the file can be pretty big, i'd like to avoid iterations. That works quite well for the first format "100.000" if i import it with an dictionary an setting 'amount':float. But i run into trouble with the second format. Is there a way to create a specific format in the dictionary?
import pandas as pd
datatypes={'Customer Number':int,'Account Number':int,'JE Entry':float}
Stack = 'stackUTF.csv'
delimiter = '|'
try:
dfStack = pd.read_csv(Stack, sep=delimiter, decimal=',', encoding='utf-8', dtype=datatypes)
except:
print("not known format recognized")
.csv with one point format:
Customer Number|Account Number|JE Entry|
123456|123123123|100.000
.csv german format
Customer Number|Account Number|JE Entry|
123456|123123123|100.000,01