02-01-2022 06:29 AM
Good afternoon .
I read the *.csv file. and it uses a dot "." as a separator in several columns, and a comma "," in some of them.
Example
1.2 1.4 1,5 1.3 1,3 1,5 1.5
1.5 1.3 1,1 1.4 1,4 1,3 1.2
How to make all columns numeric.
02-03-2022 02:20 AM
good day
Dear colleagues, if there is no regular procedure in Diadem, maybe someone can make a script that will read all the columns and replace all "," with "." .
Thanks in advance
02-05-2022 06:10 AM - edited 02-05-2022 06:11 AM
Hi,
I support the idea of cleaning up the file before importing it. Having commas and dots mixed up is a really unusual situation, and should be managed before the file is imported to DIAdem or any other tool.
Are you using VB or Python scripts? With python, you can easily do it as follows:
# Origin and Cleaned File
txtFileOrig = r'D:\MyFolder\XX.txt'
txtFileCleaned = r'D:\MyFolder\XX_cleaned.txt'
# Open Origin File
with open(txtFileOrig, 'r') as f:
txtStrOrig = f.read()
# Clean Origin File
txtStrCleaned = txtStrOrig.replace(',','.')
# Write Cleaned File
with open(txtFileCleaned, 'w') as f:
f.write(txtStrCleaned)
With this code, you open XX.txt file, replace commas with dots, and save it as XX_cleaned.txt.
If you want to overwrite the original file, just set txtStrCleaned = txtStrOrig
If you are using VB, there is certainly a way to do it, but I should do some research (I am not that familiar with that language, but hopefully someone else will be able to give you a hand).