Sponsored Content
Top Forums Shell Programming and Scripting Reading in data sets into arrays from an input file. Post 77181 by sidamin810 on Tuesday 5th of July 2005 02:19:43 PM
Old 07-05-2005
Reading in data sets into arrays from an input file.

Hye all,

I would like some help with reading in a file in which the data is seperated by commas. for instance:

input.dat:
1,2,34,/test

for the above case, the fn. will store the values into an array -> data[] as follows:

data[0] = 1
data[1] = 2
data[2] = 34
data[3] = /test

I am trying to write this fn. but dont know how to look for a comma so that the next data can be read in. Any help will be appreciated. Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using loop reading a file,retrieving data from data base.

Hi All, I am having trouble through, I am reading the input from tab delimited file containing several records, e.g. line1 field1 field2 field3 so on.. line2 field1 field2 field3 so on.. .. .. on the basis of certain fields for each record in input file, I have to retrieve... (1 Reply)
Discussion started by: Sonu4lov
1 Replies

2. Shell Programming and Scripting

Arrays & File Reading

Ok; here is the code INCREMENT=0 #Final Count MATCH=0 #Treated as a Boolean declare -a LINEFOUR #Declared Array for FILE in $DIR; do # DIR was declared earlier test -f $FILE && ( TEMP=(sed -n '4p' $FILE) #How do I assign the fourth line of the file to TEMP? This doesn't... (1 Reply)
Discussion started by: Asylus
1 Replies

3. Shell Programming and Scripting

How to load different type of data in a file to two arrays

Hi, I have tried to find some sort of previous similar thread on this but not quite close to what I want to achieve. Basically I have two class of data in my file..e.g 1,1,1,1,1,2,yes 1,2,3,4,5,5,yes 2,3,4,5,5,5,no 1,2,3,4,4,2,no 1,1,3,4,5,2,no I wanted to read the "yes" entry to an... (5 Replies)
Discussion started by: ahjiefreak
5 Replies

4. Shell Programming and Scripting

reading input from a file

I am trying to read input for a C program (that expects input from the user) from a file using the shell command: progname < filename but it seems that the program considers the char '<' as the first input, hence causing an "error" in my program. I checked it with another program and it... (2 Replies)
Discussion started by: nadbar
2 Replies

5. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

6. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

7. Shell Programming and Scripting

Reading a .dat file in to 2 different arrays

hi all, i have a data file that contains 2 columns, names and numbers. i need to read names in to a an array call names and numbers in to an array call numbers. i also have # and blank lines in my dat file and i need to skip those when i read the dat file. how do i do this? btw, my column 1 and... (3 Replies)
Discussion started by: usustarr
3 Replies

8. Shell Programming and Scripting

How to extract specific data and count number containing sets from a file?

Hello everybody! I am quit new here and hope you can help me. Using an awk script I am trying to extract data from several files. The structure of the input files is as follows: TimeStep parameter1 parameter2 parameter3 parameter4 e.g. 1 X Y Z L 1 D H Z I 1 H Y E W 2 D H G F 2 R... (2 Replies)
Discussion started by: Daniel8472
2 Replies

9. Open Source

Splitting files using awk and reading filename value from input data

I have a process that requires me to read data from huge log files and find the most recent entry on a per-user basis. The number of users may fluctuate wildly month to month, so I can't code for it with names or a set number of variables to capture the data, and the files are large so I don't... (7 Replies)
Discussion started by: rbatte1
7 Replies

10. Shell Programming and Scripting

How to embed data instead of reading user input from an array?

Hello, I am running under ubuntu1 14.04 and I have a script which is sending given process names to vanish so that I'd see less output when I run most popular tools like top etc in terminal window. In usual method it works. Whenever I restart the system, I have to enter the same data from... (2 Replies)
Discussion started by: baris35
2 Replies
Test::RDF::Trine::Store(3pm)				User Contributed Perl Documentation			      Test::RDF::Trine::Store(3pm)

NAME
Test::RDF::Trine::Store - A collection of functions to test RDF::Trine::Stores VERSION
This document describes RDF::Trine version 1.000 SYNOPSIS
For example, to test a Memory store, do something like: use Test::RDF::Trine::Store qw(all_store_tests number_of_tests); use Test::More tests => 1 + Test::RDF::Trine::Store::number_of_tests; use RDF::Trine qw(iri variable store literal); use RDF::Trine::Store; my $data = Test::RDF::Trine::Store::create_data; my $store = RDF::Trine::Store::Memory->temporary_store(); isa_ok( $store, 'RDF::Trine::Store::Memory' ); Test::RDF::Trine::Store::all_store_tests($store, $data); DESCRIPTION
This module packages a few functions that you can call to test a RDF::Trine::Store, also if it is outside of the main RDF-Trine distribution. There are different functions that will test different parts of the functionality, but you should run them all at some point, thus for the most part, you would just like to run the "all_store_tests" function for quad stores and "all_triple_store_tests" for triple stores (i.e. stores that doesn't support named graphs). All the below functions are exported. FUNCTIONS
"number_of_tests" Returns the number of tests run with "all_store_tests". "number_of_triple_tests" Returns the number of tests run with "all_triple_store_tests". "create_data" Returns a hashref with generated test data nodes to be used by other tests. "all_store_tests ($store, $data, $todo, $args)" Will run all available tests for the given store, given the data from "create_data". You may also set a third argument to some true value to mark all tests as TODO in case the store is in development. Finally, an $args hashref can be passed. Valid keys are "update_sleep" (see the function with the same name below) and "suppress_dupe_tests" if the store should skip duplicate detection, "quads_unsupported" if the store is a triple store. "all_triple_store_tests ($store, $data, $todo, $args)" Will run tests for the given triple store, i.e. a store that only accepts triples, given the data from "create_data". You may also set a third argument to some true value to mark all tests as TODO in case the store is in development. For $args, see above. "add_quads($store, $args, @quads)" Helper function to add an array of quads to the given store. "add_triples($store, $args, @triples)" Helper function to add an array of triples to the given store. "contexts_tests( $store, $args )" Testing contexts (aka. "graphs") "add_statement_tests_simple( $store, $args, $data->{ex} )" Tests to check add_statement. "bulk_add_statement_tests_simple( $store, $args, $data->{ex} )" Tests to check add_statement. "literals_tests_simple( $store, $args, $data->{ex})" Tests to check literals support. "blank_node_tests_quads( $store, $args, $data->{ex} )" Tests to check blank node support for quads. "blank_node_tests_triples( $store, $args, $data->{ex} )" Tests to check blank node support for triples. "count_statements_tests_simple( $store, $args, $data->{ex} )" Tests to check that counts are correct. "count_statements_tests_quads( $store, $args, $data->{ex} )" Count statement tests for quads. "count_statements_tests_triples( $store, $args, $data->{ex}, $data->{nil} )" More tests for counts, with triples. "get_statements_tests_triples( $store, $args, $data->{ex} )" Tests for getting statements using triples. "get_statements_tests_quads( $store, $args, $data->{ex}, $data->{nil} )" Tests for getting statements using quads. "get_pattern_tests( $store, $args, $data->{ex} )" Tests for getting statements using with get_pattern. "remove_statement_tests( $store, $args, $data->{ex}, @{$data->{names}} );" Tests for removing statements. "update_sleep ( \%args )" If $args{ update_sleep } is defined, sleeps for that many seconds. This function is called after update operations to aid in testing stores that perform updates asynchronously. BUGS
Please report any bugs or feature requests to through the GitHub web interface at <https://github.com/kasei/perlrdf/issues>. AUTHOR
Gregory Todd Williams <gwilliams@cpan.org> and Kjetil Kjernsmo <kjetilk@cpan.org> perl v5.14.2 2012-06-29 Test::RDF::Trine::Store(3pm)
All times are GMT -4. The time now is 10:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy