Page 1 of 1
select a column of data
Posted: Fri Jan 14, 2011 5:26 pm
by djehres
If I have a data file delimited by | how do I select just the first column of data?
1929393|dafda|d0354
492394|flat|dl303
239095860|daeio|3901
If I have thousands of rows of data like this how do I select and pull just the first column?
thanks.
Posted: Fri Jan 14, 2011 9:17 pm
by ACRobin
There is probably a way of doing what you want with a regular expression, but here is another:
do a find replace on the field separators (the pipe symbols) and replace with tabs (\t) - this should line up your columns.
Use Block Select mode and select the column you want.
cut and paste into a new document.
Job done.
You will need to use a fixed font and in the new document you can set the preferences for the document to get of any trailing tabs and spaces.
Posted: Sun Jan 16, 2011 1:27 pm
by ak47wong
ACRobin's idea works, but needs some tweaking:
Firstly, replacing with "\t" only works if you select the Regular expression check box. Then, if you have POSIX regular expression syntax enabled under Configure->Preferences->Editor, you need to use "\|" as the Find string rather than just "|".
Secondly, you would need to increase the tab spacing to make the columns line up. Under View->Document Properties->Tabulation, set Default tab spacing to a value larger than the length of the longest value in the first column. In the example, "239095860" is the longest value, which is 9 characters in length, so you would need to set the tab spacing to at least 10.
It seems to me that it would be easier just to delete everything after the first delimiter using a Replace operation:
Find what: \|.*
Replace with: (nothing)
Select the Regular expression check box
Click Replace All
This assumes you have POSIX regular expression syntax enabled as described above.
Posted: Wed May 25, 2011 8:14 pm
by actroid
This work for me thanks.....how about if i would to select second column or the thirth column only ...tq
Posted: Thu May 26, 2011 12:14 am
by ak47wong
You can modify the find and replace operation described above.
To keep just the second column:
Find what: (.*)\|(.*)\|(.*)
Replace with: \2
To keep the third column:
Find what: (.*)\|(.*)\|(.*)
Replace with: \3
Posted: Sun Jul 10, 2011 5:49 pm
by runderw
could you show me how to keep column 2 and 3
i try this
Find what: (.*)\|(.*)\|(.*)
Replace with: \2\3
but | also remove i would like keep | after the column 2
Posted: Mon Jul 11, 2011 8:45 am
by ak47wong
There are a number of ways to do it, but the easiest is just to put the vertical bar back into the replacement expression:
Find what: (.*)\|(.*)\|(.*)
Replace with: \2|\3