Select-String to search only first column in .CSV
Hello all,
I'm wondering if anyone knows a way to only search the first column of a .CSV file using Select-String. I guess I could probably import-csv and pipe the first column to select-string, but I was wondering if Select-string has this capability within itself?
Yes, a "large file that I only need a few lines from" is more the issue. And I was also just curious if Select-String had such functionality. For the file I am reading, it has over 23,000 lines (13MB), and there is a significant
performance increase with using select-string (over %4000 increase) :
Using Import-CSV and Where-Object: around 5.938 seconds
Using Select-String: around 0.138 seconds
Thus, if I have several strings that I want to search the file for, I would prefer to use Select-String. I suppose I could just do the following?
1. Use Select-string to search the file for each string I need to search for
2. Once I'm done searching for all strings, I can query the resultant data set to be sure the string is in the first column of each record in the dataset
3. If the string is not in the first column in the resultant data set, I can just remove the record.
Am I way off base here?
Similar Messages
-
Is it possible to search only one column in a multi column data store?
Assume I create a context index using a multi column datastore for the columns first_name, middle_name, and last_name.
Then I can search all of the columns in the index using contains().
Is there any way to use contains() to just search one of the columns in a multi column datastore - just last_name for instance?
In some cases a want to search all of the columns, in other cases just one of the columns.Yes, see the doc:
http://download.oracle.com/docs/cd/B14117_01/text.101/b10730/cdatadic.htm#i1006391
If you use the default behaviour, then your column data will be separated by XML-like tags.
<first_name>John</first_name><middle_name>Peter</middle_name><last_name>Doe</last_name>
You would then need to EITHER define each of these as sections, or use "auto_section_group". You can then search on them using
... contains (col, 'peter within middle_name') >0
See example:
SQL> drop table t;
Table dropped.
SQL> create table t (first varchar2(20), middle varchar2(20), last varchar2(20));
Table created.
SQL> insert into t values ('John', 'Peter', 'Doe');
1 row created.
SQL> insert into t values ('Peter', 'Frederik', 'Smith');
1 row created.
SQL> exec ctx_ddl.drop_preference('my_mcds')
PL/SQL procedure successfully completed.
SQL> exec ctx_ddl.create_preference('my_mcds', 'multi_column_datastore')
PL/SQL procedure successfully completed.
SQL> exec ctx_ddl.set_attribute('my_mcds', 'columns', 'first,middle,last')
PL/SQL procedure successfully completed.
SQL> create index ti on t (first) indextype is ctxsys.context
2 parameters ('datastore my_mcds section group ctxsys.auto_section_group');
Index created.
SQL> select * from t where contains (first, 'peter')>0;
FIRST MIDDLE LAST
John Peter Doe
Peter Frederik Smith
SQL> select * from t where contains (first, 'peter within middle')>0;
FIRST MIDDLE LAST
John Peter Doe -
System only loading the first column from csv
Trying to load data from Excel saved as csv, but the preview and PSA shows data loaded only for the first column from the csv file. All other columns are not loaded from the csv. Changed the lengths of the fields from the datasource to match the ones in the csv to 8, but it only seems to load the first column. What could be the cause?
Hi
Check the file format once and general tab in Data source(make sour you selected comma separated file and symbol)
check below link
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/01ed2fe3811a77e10000000a422035/frameset.htm
Regards,
Venkatesh -
All the data getting exported in the first column of csv while exporting
Hi All,
In 11.5.10.2, I have a page with advanced table region. Am using OA Framework's export button to export the results.
But, problem is, All the results are getting exported in the first column of the output .csv file. Why such a behavior?
Profile Option of 'Export MIME Type' value is text/text-separted-values.
Any ideas would be of timely help. Thanks.
Regards, SooryaFrom OAF standpoint, it just exports the data. Data interpretation is completely dependent on client machine and excel setups.
Please check the Data-->Text to Columns wizard where we can specify the delimiter(s) on excel.
Not sure if this can be set up in Apps, so that we need not change on every end-user machine.
Hope this helps.
-- Thanks -
In Search - Only first ten name displays
Dear All,
When I search for a name,only top ten relevant names pops out,for more information please check the attachment. is it bug or Google chrome impact ?.
Thanks
Agasthuri
PS: I was looking for name "Amit Srivastava" the search result pop out only ten names, actually the user name "Amit Srivastava" is more than ten, I am unable to scroll the list...Hi Doss,
You can click on select people option at rigth side(from your screen, against to search function)
on next screen, click on search tab and scn user name and search it.you will get same/similar names with more pages.
Thanks -
Problem in updating first column header in JTable
hi
I am using JTable in my application. I want to change first column name of JTable every time when a JList is selected. I am using DefaultTableModel for JTable. I added first column in Constructor and another in a method. I have to edit only first column header. How can i do this???
I used this code but it is not working.
table.getColumnModel().getColumn(0).setHeaderValue("Name of column");
table.getTableHeader().resizeAndRepaint();
Your help will be appreciated.
Thanks in advance
Sonaltable.getColumnModel().getColumn(0).setHeaderValue("Name of column");
table.getTableHeader().repaint();Works for me so post a SSCCE ( http://www.sscce.org/ ) that shows the problem. -
How to sort a 2 dim. array by the first column?
Hi there,
I need to know, how to sort a 2 dim. String array by the first column, which means "string[0][x]".
I think, I have to implement a new comparator class. But how?
Thanks in advance for any helpI need to know, how to sort a 2 dim. String
array by the first column, which means
"string[0][x]".You want to sort the array using the first element in each row and that element is a String?
Let's forget about generics. Say you want to supply a Comparator. The compare method should decide the order between elements when passed two element objects. In a two-dimensional array the elements will be one-dimentional arrays and you use the first element in those arrays, like
public int compare(Object s1, Object s2) {
String[] a1 = (String[]) s1; // first row array
String[] a2 = (String[]) s2; // second row array
return a1[0].compareTo(a2[0]); // compare first element of row arrays
} -
WebCats - Only 4 characters of first column in search help get transferred
Hi Henning,
I hope you can help me -
When I select a search help for an input field (Operation) which is a second field in search help, the system is not tranferring the selected object into the time sheet, instead it transfer first 4 characters of very first column (Network). I also checked related OSS Notes: 359620 / 357001 / 355690 / 369056 on my system and all seems to be applied long back.
We are on SAP vers 6.2.
Please advise.
Regards.
Pras DurafeHi Darren,
I have branched your message into a new topic because it didn't belong to the topic of the old thread. Please provide the exact patchlevel of your ITS 6.20.
Best regards,
Henning. -
How to select only first few values in a Column
Hi, in one of the column of type SDO_GEOMETRY. In that column we have many values. Example : *(-6.33787700000002, 56.547309, -6.33786800000001, 56.547279, -6.33781400000001, 56.547249, -6.33776900000001)*
I wanted to know how can i select only first two or last two values from within the column.
Eg: i want only -6.33787700000002, 56.547309 to be displayed
ThanksHi,
Are the value specified here are multirow or single row data?
if it is multi row, Karthick solution should work. Else if it is a single row then try this
with T as
select '-6.33787700000002, 56.547309, -6.33786800000001, 56.547279, -6.33781400000001, 56.547249, -6.33776900000001' SDO_GEOMETRY from dual
-- end of sample data
select substr(SDO_GEOMETRY,1,instr(SDO_GEOMETRY,',',1,&cnt)-1) Output from T
PRAZY@11gR2> /
Enter value for cnt: 2
OUTPUT
-6.33787700000002, 56.547309
Elapsed: 00:00:00.05And remember, while posting questions it is good to specify your DB version with clear sample data and required output.
HTH,
Prazy -
Read data in the first column selected in a Multicolumn listbox
When a row is selected in a multicolumn listbox (1 item), how do I go about reading the data in the first column?
Solved!
Go to Solution.The multicolumn listbox itself is numeric array data type. If you have allowed selection of only 1 item and selection mode of select entire row, it returns the row number. Use the "Item Names" property node to return a 2d array of strings of the items in your box. Index it by the row from the value of the listbox and column 0. See attached code.
Charles Chickering
Architecture is art with rules.
...and the rules are more like guidelines
Attachments:
MultiColumnListbox.vi 5 KB -
(JTable) How can i get the first columns cell in a selected row?
Hello. I am trying to figure out how i can get the first columns cell within a selected row no matter what cell is selected in that row. I have a class that extends AbstractTableModel which represents the table. Now i have another class that extends DefaultSelectionModel. Each model is added to the JTable via setModel(TableModel dataModel), setSelectionModel(ListSelectionModel newModel). Now i don't understand what i have to return from getMaxSelectionIndex(). Any ides? Thanks.
class xTableModel extends AbstractTableModel{
private static String[] cols;
private Object[][] data;
public void setTableModel(Object data[][], String[] cols){
this.cols = cols;
this.data = data;
public String getColumnName(int col){
return cols[col];
public int getRowCount() {
return data.length;
public Object getValueAt(int row, int col) {
return data[row][col];
public void setValueAt(Object value,int row,int col){
data[row][col]=value;
public int getColumnCount(){
return cols.length;
class ColumnListenerModel extends DefaultListSelectionModel{
public int getMaxSelectionIndex(){}int row = table.getSelectedRow();
Object data = table.getValueAt(row, 0); -
SQL Developer dropping first column in a SQL SELECT
Am not too certain who to report this to... but I just noticed that SQL Developer will not return the first column in a SELECT statement when there is a comment just after the SELECT reserved word when running the query in the SQL Worksheet. For instance:
SELECT -- > HEADER INFORMATION STARTS HERE <--
w.stu_id HDR_STU_ID,
w.wiser_id HDR_WISER_ID,
iep.wiep_id HDR_WIEP_ID,
sis.wisis_id HDR_WISIS_ID,
FROM wiser_exit exit
INNER JOIN wiser w
ON exit.wiser_id = w.wiser_id
INNER JOIN wiser_iep iep
ON w.wiser_id = iep.wiser_id
INNER JOIN vw_wiser_iep_sis sis
ON iep.wiep_id = sis.wiep_id
will just return columns 2 - 4 (HDR_WISER_ID, HDR_WIEP_ID, and HDR_WISIS_ID), and NOT column HDR_STU_ID.
I verified this by running the same query in SQL Commands in the SQL Workshop of APEX, and the resultset returned all the columns including HDR_STU_ID.
Just ran another quick test in SQL Developer, and get the same results from a SELECT against a single table:
SELECT -- > HEADER INFORMATION STARTS HERE <--
county_cd,
odd_even_flg,
street_name
FROM dime
Did not return the county_cd column.
I know, it's just a minor quirk, but I thought I would mention it.John,
Thank you. I replaced the '--' comments with the '/*' '*/' style and it picked up the first column.
I guess I'll just have to break an old habit I've been doing for years for comments. Dang, I hope all that old code doesn't break...
Thomas
Spoke too soon. I followed up by checking what Oracle's 'Oracle Database 10g The Complete Reference' had to say about the issue of using '--' for comments and under '-- (Comment)' it says "-- tells oracle a comment has begun. Everything from that point to the end of the line is treated as a comment. These delimiters are used only within SQL itself or in PL/SQL ..."
So I guess I can continue using '--', but need to keep in mind that in certain circumstances it might not work as expected. YMMV
Edited by: Thomas 8246 on Feb 19, 2010 8:09 PM -
To take only first 12 chars doing SELECT
Dear ABAPers
I am doing
SELECT single * from TAB
where A = MYKEY.
if SY-SUBRC=0.
MYKEY2 = TAB-A.
endif.
The question is u2013 I need to take(analyse) only first 12 chars of A .
Say, A is 20 chars, MYKEY is 12 chars.
Is that possible to catch only first 12 chars of A in u201Cselectu201D statement?
If yes, provide the code please.
THANK YOU!Try something like this,
data: var type string.
concatenate MYKEY '%' into var.
SELECT single * from TAB
where A like var.
if SY-SUBRC=0.
MYKEY2 = TAB-A.
endif.
Vikranth -
Object browser displays only First 31 columns in Data section of a table.
I need to download data from a table which has almost 60 columns. When i selected table from object browser and clicked on data section of this table, only first 31 columns are displayed and when clicked on download, only the data for those 31 columns is displayed. How to download data of all colums of this table
Hello Jim
I have the same problem, but my limit is 21 columns. I think the limit is caused by the DataReader SchemaTable. Check the following value:
IDataReader.GetSchemaTable().Columns.Count
Columns in the SchemaTable are Metadata (ColumnName, ColumnSize, DataType, AllowDBNull...), the columns that are selected with the DataReader are stored in the SchemaTable Rows Property.
For Oracle and SQLServer i used this workaround:
DataTable dataTable = IDataReader.GetSchemaTable();
while (dataTable.Columns.Count < dataTable.Rows.Count)
dataTable.Columns.Add("Dummy" + dataTable.Columns.Count.ToString(), typeof(bool));
I think developpers of CR use the Columns.Count instead of Rows.Count property when getting the data out of the DataReader.
Regards,
Walter -
LDAP Addressbook search - match first letter only
According to the SPA500 Admin Guide, a LDAP query will search on every letter:
"This searches for the text string anywhere in the beginning, middle, or at the end of a name."
Would it be possible to search only on the first letter of a name?
ErikEric, I don't know if you ever solved this request.
In the search syntax you will see the "$VALUE" criteria bounded by two "*". These serve as wildcard matches. If you simply delete the first "*" before $VALUE your match will start at the beginning. Likewise if you remove the second "*" instead the search will try to match at the end. If you remove both it will look for an exact match.
John
Maybe you are looking for
-
Standard Edition / Apache Server
Since there exists absolutely no information that I can find... including in the manual that came with SE, I need to know is SE only installable as a stand alone version, which Adobe recomends you don't run as a production server, and which during th
-
where should we put the images in the par file. I added them in images folder but its not accessible when i use this <hbj:image id="Image" tooltip="Thumbnails" src="images/image.JPG" alt="Image"> </hbj:image>
-
Hi I have the following SQL query select (count(select status from tbl_issues where status = 'Open' or status ='On-Hold') - count(select status from tbl_issues where status = 'Closed')) value , 100 max_value from tbl_issues when I save changes it com
-
How do I reduce the size of a PDF file for emailing?
I have scanned a document on my Canon Printer. The size is very large about 14 Megabytes. I do not know how to reduce the size so that I can send it via Mail. I have searched HELP but have not as yet found an answer. One suggestion was that in my
-
Button/tab page selections fail to respond
we have a number of web-sites built with VS 2012 that normally run okay, but on occasion internal tab or button selections that usually result in a page change within the application fail to respond. When this occurs the mouse over will display the