Sponsored Content
Top Forums Shell Programming and Scripting Help with datafile parsing and creating spreadsheet Post 302632329 by inditopgun on Sunday 29th of April 2012 08:56:12 PM
Old 04-29-2012
First of all, appreciate your time in helping me out.

Apologies for not making it clear. Let me start all over again and to make it easy, lets make prune some additional details and lay down some hard restrictions :

1. Let's assume there is no more the student_type (TEMP or PERM) data point
2. Let's assume each student takes precisely 8 courses (which have same course names) and for each course there are there are 6 variable pieces of information separated by commas on a single row. So this means for each student, there will be precisely 8 rows in the input file, containing student_name, course_name followed by 6 pieces of variable information for each student.

Code:
STUDENT1, COURSE1, COURSE1_VAR1, COURSE1_VAR2,..COURSE1_VAR6
STUDENT1, COURSE2, COURSE2_VAR1, COURSE2_VAR2,..COURSE2_VAR6
..
..
STUDENT1, COURSE8, COURSE8_VAR1, COURSE8_VAR2,..COURSE8_VAR6
..
..
STUDENTn, COURSE1,COURSE1_VAR1, COURSE1_VAR2,..COURSE1_VAR6
STUDENTn, COURSE2,COURSE2_VAR1, COURSE2_VAR2,..COURSE2_VAR6
..
..
STUDENTn, COURSE8,COURSE8_VAR1, COURSE8_VAR2,..COURSE8_VAR6

In the output, ALL data for each student should be represented in a single column in Excel.


Code:
STUDENT1, STUDENT2, STUDENT3 ......STUDENTn
COURSE1_VAR1, COURSE1_VAR1,.. COURSE1_VAR1..
COURSE1_VAR2, COURSE1_VAR2,.. COURSE1_VAR2...
..
COURSE1_VAR6, COURSE1_VAR6,.. COURSE1_VAR6
COURSE2_VAR1, COURSE2_VAR1,.. COURSE2_VAR1..
COURSE2_VAR2, COURSE2_VAR2,.. COURSE2_VAR2...
..
COURSE2_VAR6, COURSE2_VAR6,.. COURSE2_VAR6
..
COURSE8_VAR1, COURSE8_VAR1,.. COURSE8_VAR1..
COURSE8_VAR2, COURSE8_VAR2,.. COURSE8_VAR2...
..
COURSE8_VAR6, COURSE8_VAR6,.. COURSE8_VAR6

So as you can see the COURSE1 thru COURSE8 have now become the row labels and STUDENT names have become the column labels. So it is kind of transpose of matrix, in some ways.

Once again I appreciate your time!

Last edited by Scrutinizer; 05-03-2012 at 03:16 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace one section in a datafile

Hi: First, this is not a homework problem. I just need enough of a hint to get this going... My datafile (dataf.in) is made up of 10 sections. Each section begins with & and with && So it looks like this:------------------------------------- &section1 ...etc... && &section2 ...etc...... (4 Replies)
Discussion started by: Paprika
4 Replies

2. Solaris

oracle datafile *dbf

Hi ,,,, I have move an oracle db from old server to a new server ( solaris 5.9 is the operating system ) my problem is that to new server the datafile ( *.dbf ) are in a different path ..... example old : /export/home/data/blobs ........... new /oracle/data/blobs....... how i can... (3 Replies)
Discussion started by: tt155
3 Replies

3. Shell Programming and Scripting

selective positions from a datafile

Hi dear friends, Im writing a shell script which has to select the strings based on the position. but the problem is there is no field seperator. Normally a datafile contains 2000 records (lines) and each line is of size 500 charecters. I want to select the fields from all the lines which... (10 Replies)
Discussion started by: ganapati
10 Replies

4. UNIX for Dummies Questions & Answers

Append filename to datafile

I am working on an shell script which checks for all the file starting with abc*.* and if file found then the filelines need to append the file name in begining can some one help with the filename appending... for i in `ls $filename*.csv` do echo $i --- NEED to append file name befor... (3 Replies)
Discussion started by: Satyagiri
3 Replies

5. Shell Programming and Scripting

Combine a datafile with Master datafile, emergent!

Hi guys, my supervisor has asked me to solve the problem in 7 days, I've taken 3 days to think about it but couldn't figure out any idea. Please give me some thoughts with the following problem, I have index.database that has only index date: 1994 1995 1996 1997 1998 1999 I have... (6 Replies)
Discussion started by: onthetopo
6 Replies

6. UNIX for Advanced & Expert Users

How do we know which processis creating a datafile

Hi, Is there any way we can find out which process is creating a partucular datafile.I know the user and group but i am just curios to know is there any way to find the process. Thanks (7 Replies)
Discussion started by: ukatru
7 Replies

7. Shell Programming and Scripting

sorting the datafile in an order given in second datafile

Hi, I have two files: first input file is having 7-8 columns, and second data file is like I want to arrange my datafile1 in the order given in second data file, by comparing the seconddatafile with the second column of first file and print the entire line....also if any... (2 Replies)
Discussion started by: CAch
2 Replies

8. Shell Programming and Scripting

Parsing with Name value pair and creating a normalized file

I have url string as follows and I need to parse the name value pair into fields /rows event_id date time payload 1329130951 20120214 22.30.40... (1 Reply)
Discussion started by: smee
1 Replies

9. Shell Programming and Scripting

Validating a datafile with the datatypes

I have two input files 1)datafile 2)metadata file. I have a metadata file like: field1datatypeformat1number2string3dateyy-mm-dd I have a data file like: 1234abc12-8-16 xyz234512-9-163456acd14-08-12 In the first row there is no correction as everything is inline with the metadata.... (3 Replies)
Discussion started by: bikky6
3 Replies

10. Shell Programming and Scripting

Parsing a log file and creating a report script

The log file is huge and lot of information, i would like to parse and make a report . below is the log file looks like: REPORT DATE: Mon Aug 10 04:16:17 CDT 2017 SYSTEN VER: v1.3.0.9 TERMINAL TYPE: prod SYSTEM: nb11cu51 UPTIME: 04:16AM up 182 days 57 mins min MODEL, TYPE, and SN:... (8 Replies)
Discussion started by: amir07
8 Replies
PDOSTATEMENT.FETCHCOLUMN(3)						 1					       PDOSTATEMENT.FETCHCOLUMN(3)

PDOStatement::fetchColumn - Returns a single column from the next row of a result set

SYNOPSIS
public mixed PDOStatement::fetchColumn ([int $column_number]) DESCRIPTION
Returns a single column from the next row of a result set or FALSE if there are no more rows. Note PDOStatement.fetchColumn(3) should not be used to retrieve boolean columns, as it is impossible to distinguish a value of FALSE from there being no more rows to retrieve. Use PDOStatement.fetch(3) instead. PARAMETERS
o $column_number - 0-indexed number of the column you wish to retrieve from the row. If no value is supplied, PDOStatement.fetchColumn(3) fetches the first column. RETURN VALUES
PDOStatement.fetchColumn(3) returns a single column in the next row of a result set. Warning There is no way to return another column from the same row if you use PDOStatement.fetchColumn(3) to retrieve data. EXAMPLES
Example #1 Return first column of the next row <?php $sth = $dbh->prepare("SELECT name, colour FROM fruit"); $sth->execute(); print("Fetch the first column from the first row in the result set: "); $result = $sth->fetchColumn(); print("name = $result "); print("Fetch the second column from the second row in the result set: "); $result = $sth->fetchColumn(1); print("colour = $result "); ?> The above example will output: Fetch the first column from the first row in the result set: name = lemon Fetch the second column from the second row in the result set: colour = red SEE ALSO
PDO.query(3), PDOStatement.fetch(3), PDOStatement.fetchAll(3), PDO.prepare(3), PDOStatement.setFetchMode(3). PHP Documentation Group PDOSTATEMENT.FETCHCOLUMN(3)
All times are GMT -4. The time now is 07:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy