Copy link to clipboard
Copied
I have a table in file in which there is column in which there are about 70 numbers .ie in 70 cells
Is there any script to apply thousand separator to those numbers
eg 12500 to 12,500 or 12.500
thanks
You could do it with three Grep queries:
Find what: (\d)\Z
Change to: $1~%
Find what: (\d\d)(?=(\d\d\d)+\b)
Change to: $1,
Find what: ~%\Z
Change to: <Leave blank>
But running three queries is a drag, so this script runs them:
...app.findGrepPreferences = app.changeGrepPreferences = null;
function change (f, r) {
app.findGrepPreferences.findWhat = f;
app.changeGrepPreferences.changeTo = r;
app.documents[0].changeGrep();
}
change ('(\\d)\\Z', '$1~%');
change ('(\\d\\d)(?=(\\d\\d\\d)+\\b)', '$1,');
change (
Copy link to clipboard
Copied
I'm not a GREP expert (I hope our list experts will chime in), but I think you can set a GREP style to automatically drop the period/comma into the number strings.
Here's another quick workaround:
Should take less than a minute to do this.
You might have to save it from Excel as an .XLSX file, and then place the XLSX into InDesign in order to preserve the table structure.
Copy link to clipboard
Copied
abhijeett89122812 wrote
I have a table in file in which there is column in which there are about 70 numbers .ie in 70 cells
Is there any script to apply thousand separator to those numbers
eg 12500 to 12,500 or 12.500
thanks
What does "or" mean?
Do you have two different languages in the same document?
Regards,
Uwe
Copy link to clipboard
Copied
You could do it with three Grep queries:
Find what: (\d)\Z
Change to: $1~%
Find what: (\d\d)(?=(\d\d\d)+\b)
Change to: $1,
Find what: ~%\Z
Change to: <Leave blank>
But running three queries is a drag, so this script runs them:
app.findGrepPreferences = app.changeGrepPreferences = null;
function change (f, r) {
app.findGrepPreferences.findWhat = f;
app.changeGrepPreferences.changeTo = r;
app.documents[0].changeGrep();
}
change ('(\\d)\\Z', '$1~%');
change ('(\\d\\d)(?=(\\d\\d\\d)+\\b)', '$1,');
change ('~%\\Z', '');
The first query adds a sixth-space at the end of every cell. I forget now why that's necessary (it's been a while), but it is. Then the second query inserts the thousands separators (here, a comma; to change that to a dot, replace $1, in line 10 with a $1.). Finally, the third query removes those cell-final sixth-spaces.
This one doesn't add separators in 4-digit numbers. To do that, in line 10 change '(\\d\\d)(?=(\\d\\d\\d)+\\b)' to '(\\d)(?=(\\d\\d\\d)+\\b)',
P.
Copy link to clipboard
Copied
There's no need to run three GREP expressions; one is sufficient. In the Find input, enter:
(\d)(\d{3})(?!\d)
, and in the Replace input, enter:
$1\,$2
Because this GREP logic ensures that the value to the right is not a digit, you can understand it as working from right to left.
Therefore, this method can be executed repeatedly without errors.
Copy link to clipboard
Copied
thank you very much alrin0000. works perfect!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now