From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Numeric "." and ","

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.

0 Kudos
Message 1 of 3
(972 Views)

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

0 Kudos
Message 2 of 3
(931 Views)

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).

0 Kudos
Message 3 of 3
(919 Views)