Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Read Data from text file and write to text file

Status
Not open for further replies.

murari208@gmail.com

Newbie level 3
Joined
Jan 1, 2015
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
19
hi all,
there is a text file containing some data like number of samples , time ,x0...
i need to read only times of the sample and write it in a text file since i am taking large number of samples .can you please help me in solving this.
 

How about the following short perl program.

Code Perl - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/local/bin/perl
use 5.012;
use warnings;
use strict;
 
# extract time in a file with the following format:
# number_of_samples, time, x0, x1, ....
# Expects that the data is comma+1space separated, change the split line if you have a different separator.
my $filename = $ARGV[0];
open (my $read_fh, '<', $filename);
 
while (my $line = <$read_fh>) {
  my @data = split /, /, $line; # split on comma+1space
  if (length $data[1]) {print "$data[1]\n"}
}
 
close ($read_fh);


If you want the output in another file just redirect the output on the command line to another file.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top