TableTool
TableTool copied to clipboard
Numeric only cells drop leading 0
This is a huge problem with most CSV editing tools, even Microsoft Excel. I often am dealing with large CSV files that have a number of entries consisting of numbers that must retain a leading 0 digit. I understand why it does this from a programming point of view, but it's very frustrating.
Also I had this problem, and I did a little investigation, a solution was found that by modifying one line code in CSVReader.m
regex = [NSRegularExpression regularExpressionWithPattern:[NSString stringWithFormat:@"^\\s*[+-]?(\[1-9]+\\%@?\\d*|\\*\\%@?\\d+|\[0]+\\%@+\\d*)([eE][+-]?\\d+)?\\s*$",_config.decimalMark,_config.decimalMark,_config.decimalMark] options:0 error:NULL];
Jacob, thanks a lot for this simple and efficient application, could you please update it in the new version.
@YWangScience Could you explain in a bit more detail what your proposed change does?
@jakob The logic is if a value has no decimalMark (not a float) and it begins with 0, your program considers it as a string rather than a number. For example, 090618 is a string, shall not be cut to 90618. I simply separated \d to [1-9] and 0, surely you can construct a better regex.
@YWangScience thanks for explaining. This makes a lot of sense! (Reading regex expressions is not so easy....)
Would you like to make a pull request with your changes? (If you do, it would also be a good idea to add test cases to make sure that the proposed changes work, and I don't accidentally break them in the future).
@YWangScience Thank you so much! Your help saved me a lot of trouble.
@YWangScience Can you please submit as a pull request.
@jakob thanks for this tool and @YWangScience thanks for your investigation and solution for this issue. Can this fix please be updated into a new version of the product? This is preventing us using teh tool to work with mobile phone numbers, which include a leading zero by default in my country
Has this been merged? I just downloaded the app from the App Store and it is still messing up my leading 0's...
+41 on this. Table tool should not mess with data. This is one of the reasons we use CSV at all. Hoping that @MEffing PR could be merged soon.
It's 2023 and I can't believe this is still an open issue.