I'm trying to process my bank's data, which is always formed by lines with 5 fields separated by semicolons. Until recently, it used to write the numbers in the "1234,56" format, and I processed them by
Import[NotebookDirectory[] <> "cc.wri", "Table",
"NumberPoint" -> ",", "FieldSeparators" -> {";"}]
Recently the bank started using the "1,234.56" format, and since I prefer to use a single file containing all my transactions history, I am wondering if it is possible to read from a file both type of number formats.
I tried using ToExpression[]
, but without success, and it seems that NumberPoint
doesnt allow for multiple choices
-> fake cc.wri file: https://pastebin.com/MviN6SBC
update: I checked that this works, but still dont know if it's the best way to do it:
a=Import[NotebookDirectory[] <> "cc.wri", "Table",
"NumberPoint" -> ",", "FieldSeparators" -> {";"}]
a4 =
Map[If[NumberQ[#], #, Internal`StringToDouble[#]] &,
a\[Transpose][[4]]]
(Internal``StringToDouble
idea from Faster way to convert real strings into numbers)