Sponsored Content
Top Forums Shell Programming and Scripting Struggling with arrays and delimited file Post 302285368 by cfajohnson on Sunday 8th of February 2009 10:14:10 PM
Old 02-08-2009
Quote:
Originally Posted by corona688
i'm not sure what you want the array for when you can deal with them one-by-one instead of storing them, but here goes:

Code:
# make read split apart on ','
ifs=","
names=()
sites=()
n=0
while read name site
do
        echo "displaying $name $site"
        names[$n]="$name"
        sites[$n]="$site"
        n=$((n+1))


No need for a counter:

Code:
names[${#names[@]}]="$name"
sites[${#sites[@]}]="$site"

Quote:
Code:
done < input.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Tab delimited file to Comma delimited file in Unix

Hi, Can anyone let me know on how to convert a Tab delimited file to Comma delimited file in Unix Thanks!! (22 Replies)
Discussion started by: charan81
22 Replies

2. Shell Programming and Scripting

Struggling with a text file

Hi, I am struggling with the following... I try to grep out information of a text file I got with lynx, a text browser. The text file I get from lynx with dump is attached in the bottom. What I would like to get is another file containing the astro-ph/98324 (number) and title and list of... (13 Replies)
Discussion started by: pau
13 Replies

3. UNIX for Advanced & Expert Users

Help- Unix File Compare- Struggling

I had posted this earlier about 3 weeks ago and had recieved a response and I did sort both the files and the comm command is still not working. Can someone please assist me, I would really appreciate it. Below is what I am trying to do I need to compare File A with File B and create FILE C... (2 Replies)
Discussion started by: guiguy
2 Replies

4. Shell Programming and Scripting

convert a pipe delimited file to a':" delimited file

i have a file whose data is like this:: osr_pe_assign|-120|wg000d@att.com|4| osr_evt|-21|wg000d@att.com|4| pe_avail|-21|wg000d@att.com|4| osr_svt|-11|wg000d@att.com|4| pe_mop|-13|wg000d@att.com|4| instar_ready|-35|wg000d@att.com|4| nsdnet_ready|-90|wg000d@att.com|4|... (6 Replies)
Discussion started by: priyanka3006
6 Replies

5. Programming

question about int arrays and file pointer arrays

if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies

6. Shell Programming and Scripting

How to convert a space delimited file into a pipe delimited file using shellscript?

Hi All, I have space delimited file similar to the one as shown below.. I need to convert it as a pipe delimited, the values inside the pipe delimited file should be as highlighted... AA ATIU2345098809 009697 005374 BB ATIU2345097809 005445 006518 CC ATIU9685098809 003215 003571 DD... (7 Replies)
Discussion started by: nithins007
7 Replies

7. Shell Programming and Scripting

Parsing file: struggling against sed command

Hello fellows, Sure you can help this poor guy that is struggling against sed command, being unable to tame it I have a lot of files like this: From this one, I need to obtain values highlighted in bold/red To do so, I am executing this piece of code inside a loop: ... (10 Replies)
Discussion started by: manolain
10 Replies

8. Shell Programming and Scripting

Help with converting Pipe delimited file to Tab Delimited

I have a file which was pipe delimited, I need to make it tab delimited. I tried with sed but no use cat file | sed 's/|//t/g' The above command substituted "/t" not tab in the place of pipe. Sample file: abc|123|2012-01-30|2012-04-28|xyz have to convert to: abc 123... (6 Replies)
Discussion started by: karumudi7
6 Replies

9. Shell Programming and Scripting

How to make tab delimited file to space delimited?

Hi How to make tab delimited file to space delimited? in put file: ABC kgy jkh ghj ash kjl o/p file: ABC kgy jkh ghj ash kjl Use code tags, thanks. (1 Reply)
Discussion started by: jagdishrout
1 Replies

10. UNIX for Dummies Questions & Answers

Need to convert a pipe delimited text file to tab delimited

Hi, I have a rquirement in unix as below . I have a text file with me seperated by | symbol and i need to generate a excel file through unix commands/script so that each value will go to each column. ex: Input Text file: 1|A|apple 2|B|bottle excel file to be generated as output as... (9 Replies)
Discussion started by: raja kakitapall
9 Replies
Finance::QuoteHist(3pm) 				User Contributed Perl Documentation				   Finance::QuoteHist(3pm)

NAME
Finance::QuoteHist - Perl module for fetching historical stock quotes. SYNOPSIS
use Finance::QuoteHist; $q = Finance::QuoteHist->new ( symbols => [qw(IBM UPS AMZN)], start_date => '01/01/2009', # or '1 year ago', see Date::Manip end_date => 'today', ); # Quotes foreach $row ($q->quotes()) { ($symbol, $date, $open, $high, $low, $close, $volume) = @$row; ... } # Splits foreach $row ($q->splits()) { ($symbol, $date, $post, $pre) = @$row; } # Dividends foreach $row ($q->dividends()) { ($symbol, $date, $dividend) = @$row; } # Culprit $fetch_class = $q->quote_source('IBM'); DESCRIPTION
Finance::QuoteHist is a top level interface for fetching historical stock quotes from the web. It is actually a front end to modules based on Finance::QuoteHist::Generic, the main difference being that it has a default lineup of web sites from which to attempt quote retrieval. If the prospect of mixing data from multiple sites seems scary to you, then use one of the site-specific modules directly. Unless otherwise defined via the lineup attribute, this module will select a lineup for you, the default being: Finance::QutoeHist::Yahoo Finance::QutoeHist::Google Finance::QuoteHist::QuoteMedia Finance::QutoeHist::MSN Once instantiated, this module behaves identically to the first module in the lineup, sharing all of that module's methods. Most queries will likely be handled by the first module in the lineup. If the site is down for some reason, or perhaps that site does not provide quotes for defunct ticker symbols, then the other sites in the lineup will be attempted. See Finance::QuoteHist::Generic(3) for gory details on all of the parameters and methods this module accepts. The basic interface is noted below. METHODS
The basic user interface consists of several methods, as seen in the example above. Those methods are: quotes() Returns a list of rows (or a reference to an array containing those rows, if in scalar context). Each row contains the Symbol, Date, Open, High, Low, Close, and Volume for that date. Optionally, if non-adjusted values were requested, their will be an extra element at the end of the row for the Adjusted closing price. dividends() Returns a list of rows (or a reference to an array containing those rows, if in scalar context). Each row contains the Date and amount of the Dividend, in that order. splits() Returns a list of rows (or a reference to an array containing those rows, if in scalar context). Each row contains the Date, Post split shares, and Pre split shares, in that order. source($ticker, $target) Each of these methods displays which site-specific class actually retrieved the information, if any, for a particular ticker symbol and target such as 'quote' (default), 'dividend', or 'split'. DISCLAIMER
The data returned from these modules is in no way guaranteed, nor are the developers responsible in any way for how this data (or lack thereof) is used. The interface is based on URLs and page layouts that might change at any time. Even though these modules are designed to be adaptive under these circumstances, they will at some point probably be unable to retrieve data unless fixed or provided with new parameters. Furthermore, the data from these web sites is usually not even guaranteed by the web sites themselves, and oftentimes is acquired elsewhere. See the documentation for each site-specific module for more information regarding the disclaimer for that site. AUTHOR
Matthew P. Sisk, <sisk@mojotoad.com> COPYRIGHT
Copyright (c) 2000-2011 Matthew P. Sisk. All rights reserved. All wrongs revenged. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Finance::QuoteHist::Generic(3), Finance::QuoteHist::Yahoo(3), Finance::QuoteHist::QuoteMedia(3), perl(1). perl v5.12.4 2011-08-29 Finance::QuoteHist(3pm)
All times are GMT -4. The time now is 04:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy