Hi,
Below is an example of a csv file that I am trying to make some changes to .
0,"H",1,"S","JONNY","23/11/2007",188.91,0,3000620,"","",""
"D","","","",0,1,0,**156.12,0,*156.12,0,1.00,"002","1001","","
0,"H",1,"S","JONNY","23/11/2007",1192.41,0,3000621,"","","
"D","","","",0,1,0,**98.55,0,*985.46,0,10.00,"002","1001","","
0,"H",1,"S","CASH01","23/11/2007",1605.02,0,3000643,"","","
"D","","","",0,1,0,**82.90,0,*1326.46,0,16.00,"002","1001","",
The header line doesn't need changing (it has the "H" at the beginning).The detail line however needs 2 changes ( "D" @ start of line ) .The numbers in bold italics are to be changed to 1.00 .
The number with the * before it (I placed the * there for reference purposes only ) is to be copied and replace the number with ** before it .please note the (*) (**) are not usually present on the csv file .
regards
MT
CSV file exchanging values
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
MT
- Posts: 5
- Joined: Tue Nov 06, 2007 4:27 pm
CSV file exchanging values
Last edited by MT on Thu Nov 29, 2007 8:31 am, edited 1 time in total.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
When you referred to integers did you in fact mean numbers? If so:
This assumes you are using Posix regular expression syntax:Find what: ^("D",([^,]*,){6})[^,]*,([^,]*,)([^,]*,)([^,]*,)[^,]*,
Replace with: \1\4\3\4\51.00,
[X] Regular expression
Replace All
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
^("D",([^,]*,){6})[^,]*,([^,]*,)([^,]*,)([^,]*,)[^,]*, matches
[^,]*, matches:
We glue this back together in a slightly different order and adjusted as required:
\1\4\3\4\51.00, is composed of:
Look in TextPad's help under
Reference Information | Regular Expressions,
Reference Information | Replacement Expressions and
How to... | Find and Replace Text | Use Regular Expressions.
There are many regular expression tutorials on the web, and you will find recommendations for some of them if you search this forum.
A standard reference for regular expressions is
Friedl, Jeffrey E F
Mastering Regular Expressions, 3rd ed
O'Reilly, 2006
ISBN: 0-596-52812-4
http://regex.info/
But be aware that the regular expression recogniser used by TextPad is rather weak by the standards of recent tools, so you may get frustrated if you discover a handy trick that doesn't work in TextPad.
Code: Select all
^ the beginning of a line
( start of captured text number 1
"D", the literal text: "D",
( start of captured text number 2 (but we don't use it)
[^,]*, any text not containing commas, followed by a comma
(see below)
) end of captured text number 2
{6} ... 6 times
) end of captured text number 1
[^,]*, any text not containing commas, followed by a comma
( start of captured text number 3
[^,]*, any text not containing commas, followed by a comma
) end of captured text number 3
( start of captured text number 4
[^,]*, any text not containing commas, followed by a comma
) end of captured text number 4
( start of captured text number 5
[^,]*, any text not containing commas, followed by a comma
) end of captured text number 5
[^,]*, any text not containing commas, followed by a comma
Code: Select all
[^,] any character except newline or comma
* ... any number (possibly zero) of times
, a comma
\1\4\3\4\51.00, is composed of:
Code: Select all
\1 captured text number 1
\4 captured text number 4
\3 captured text number 3
\4 captured text number 4
\5 captured text number 5
1.00 the literal text: 1.00
, a comma
Reference Information | Regular Expressions,
Reference Information | Replacement Expressions and
How to... | Find and Replace Text | Use Regular Expressions.
There are many regular expression tutorials on the web, and you will find recommendations for some of them if you search this forum.
A standard reference for regular expressions is
Friedl, Jeffrey E F
Mastering Regular Expressions, 3rd ed
O'Reilly, 2006
ISBN: 0-596-52812-4
http://regex.info/
But be aware that the regular expression recogniser used by TextPad is rather weak by the standards of recent tools, so you may get frustrated if you discover a handy trick that doesn't work in TextPad.