473,508 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading particular Column in text file

3 New Member
Hi friends,
I am facing problem in finding a code which should read particular column in text file.My code opens a file split it into an array & search the string but it search that in whole file while i want it to search in ap articular column because same string is in other columns.
My code is:

open(INFO, $file); # Open the file
open(OUT, ">OutPutFile.out");

while (<INFO>)
{

chomp($_);
@record=split(/\|/,$_);


if($_=~/(\d*\.0\sDC\sAND\s\d*\.0\sDC)/)
{
$i++;
print OUT "$i $1";
@temp=split(/\|/,$1);
$t="@temp";
$t=~s/\.0\sDC\sAND\s\d*\.0\sDC//g;
chomp($t);
print OUT "$t || V ";
$t1="@temp";
$t1=~s/\d*\.0\sDC\sAND\s//g;
$t1=~s/\.0\s\w*//g;
chomp($t1);
print OUT "$t1 || V \n";

so plz help me out.

regards
Dec 4 '06 #1
2 4261
GunnarH
83 New Member
I am facing problem in finding a code which should read particular column in text file.
@record=split(/\|/,$_);

if($_=~/(\d*\.0\sDC\sAND\s\d*\.0\sDC)/)
If you for instance are interested in the third column:
Expand|Select|Wrap|Line Numbers
  1. if ( $record[2] =~ /(\d*\.0\sDC\sAND\s\d*\.0\sDC)/ )
Dec 4 '06 #2
redalpha
3 New Member
If you for instance are interested in the third column:
Expand|Select|Wrap|Line Numbers
  1. if ( $record[2] =~ /(\d*\.0\sDC\sAND\s\d*\.0\sDC)/ )
Thanks its working
Dec 5 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2758
by: jamait | last post by:
Hi all, I m trying to read in a text file into a datatable... Not sure on how to split up the information though, regex or substrings...? sample: Col1 Col2 ...
1
1476
by: srikanth | last post by:
hi, I have one file it filled with some values in rows/colums. some times, some variables (in a particular row& column) may not be filled. depending on the kind its filled i will go for...
5
8926
by: Scott M. Lyon | last post by:
I've just discovered a bug in some code I wrote a little while ago, and I need you guys' help to fix it. My program imports data from a standard Excel Spreadsheet (just with specific column...
1
2384
by: svijay | last post by:
hi I have got a strange problem. May I know any solution for this. Here is the detailed description about the problem We have got a mainframe system and also production and development...
4
12767
by: Amit Maheshwari | last post by:
I need to read text file having data either comma seperated or tab seperated or any custom seperator and convert into a DataSet in C# . I tried Microsoft Text Driver and Microsoft.Jet.OLEDB.4.0...
6
7014
by: simchajoy2000 | last post by:
Hi, So I do actually know how to read excel into VB.NET using the following approach: With oConn2 .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & FilePath & ";Extended...
9
22476
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What...
2
2867
by: sherifffruitfly | last post by:
Hi, I'm using an adaptation of excel-reading code that's all over the internet - I don't much like or understand it, but it has worked for me in the past.... beggars can't be choosers... : ...
6
22485
by: =?Utf-8?B?UmljaA==?= | last post by:
'--this code works but only reads text into one column when contains multiple cols Dim ds1x As New DataSet Dim ConStr As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.