Sponsored Content
Full Discussion: MATRIX to CSV
Top Forums Shell Programming and Scripting MATRIX to CSV Post 302822959 by kraterions on Tuesday 18th of June 2013 12:17:01 PM
Old 06-18-2013
MATRIX to CSV

Hello friends,

A big question for the UNIX INTELLIGENCE

I have a CSV file as follows:


Code:
VALUE,USER1,relatedUSER1,relatedUSER2
-1,userA,userB,userC
1,userN,userD,userB
0,userF,userH,userG
0,userT,userH,userB
1,userN,userB,userA
-1,userA,userF,userC
0,userF,userH,userG
1,userB,userJ,userU
-1,userJ,userD,userA

There are a lot of user and their frequences and positions are random in every field!

I need as a output file a CSV as follows:

SUPERUSER,relatedUSER,TOTFrequencyrelations,(1)Frequency,(0)Frequency,(-1)Frequency,VALUE


Where:
SUPERUSER= most frequent user (in column USER1) in terms of relations to other users (descendent order)
relatedUSER= most frequent user in terms of relations to USER1
TOTFrequencyrelations = total number of relations between SUPERUSER and relatedUSER
(1)Frequency = amount of positive relations
(0)Frequency = amount of neutral relations
(-1)Frequency = amount of negative relations
Value = (1)Frequency-(-1)Frequency/[(1)Frequency+(-1)Frequency)]

Example:

Code:
SUPERUSER,relatedUSER,TOTFrequencyrelations,(1)Frequency,(0)Frequency,(-1)Frequency,VALUE
userG,userB,15,6,7,1,0....
userG,userF,10,2,4,4,0...
userG,userD,5,2,2,1,0...
userJ,userH,15,6,6,3,0...
userJ,userU,8,4,1,1,0....
userJ,userB,6,2,2,1,0....
userF,userA,12,4,5,3,0.....
userF,userH,12,5,2,5,0.....

Many thanks for your big help.

Have a nice time!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

diagonal matrix to square matrix

Hello, all! I am struggling with a short script to read a diagonal matrix for later retrieval. 1.000 0.234 0.435 0.123 0.012 0.102 0.325 0.412 0.087 0.098 1.000 0.111 0.412 0.115 0.058 0.091 0.190 0.045 0.058 1.000 0.205 0.542 0.335 0.054 0.117 0.203 0.125 1.000 0.587 0.159 0.357... (11 Replies)
Discussion started by: yifangt
11 Replies

2. Shell Programming and Scripting

2 problems: Mailing CSV file / parsing CSV for display

I have been trying to find a good solution for this seemingly simple task for 2 days, and I'm giving up and posting a thread. I hope someone can help me out! I'm on HPUX, using sqlplus, mailx, awk, have some other tools available, but can't install stuff that isn't already in place (without a... (6 Replies)
Discussion started by: soldstatic
6 Replies

3. Ubuntu

How to convert full data matrix to linearised left data matrix?

Hi all, Is there a way to convert full data matrix to linearised left data matrix? e.g full data matrix Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7 Bh1 0 0.241058 0.236129 0.244397 0.237479 0.240767 0.245245 Bh2 0.241058 0 0.240594 0.241931 0.241975 ... (8 Replies)
Discussion started by: evoll
8 Replies

4. Shell Programming and Scripting

awk? adjacency matrix to adjacency list / correlation matrix to list

Hi everyone I am very new at awk but think that that might be the best strategy for this. I have a matrix very similar to a correlation matrix and in practical terms I need to convert it into a list containing the values from the matrix (one value per line) with the first field of the line (row... (5 Replies)
Discussion started by: stonemonkey
5 Replies

5. Shell Programming and Scripting

CSV to SQL insert: Awk for strings with multiple lines in csv

Hi Fellows, I have been struggling to fix an issue in csv records to compose sql statements and have been really losing sleep over it. Here is the problem: I have csv files in the following pipe-delimited format: Column1|Column2|Column3|Column4|NEWLINE Address Type|some descriptive... (4 Replies)
Discussion started by: khayal
4 Replies

6. Shell Programming and Scripting

Perl search csv fileA where two strings exist on another csv fileB

Hi I have two csv files, with the following formats: FileA.log: Application, This occured blah Application, That occured blah Application, Also this AnotherLog, Bob did this AnotherLog, Dave did that FileB.log: Uk, London, Application, datetime, LaterDateTime, Today it had'nt... (8 Replies)
Discussion started by: PerlNewbRP
8 Replies

7. Shell Programming and Scripting

3 column .csv --> correlation matrix; awk, perl?

Greetings, salutations. I have a 3 column csv file with ~13 million rows and I would like to generate a correlation matrix. Interestingly, you all previously provided a solution to the inverse of this problem. Thread title: "awk? adjacency matrix to adjacency list / correlation matrix to list"... (6 Replies)
Discussion started by: R3353
6 Replies

8. Shell Programming and Scripting

Comparing 2 CSV files and sending the difference to a new csv file

(say) I have 2 csv files - file1.csv & file2.csv as mentioned below: file1.csv ID,version,cost 1000,1,30 2000,2,40 3000,3,50 4000,4,60 file2.csv ID,version,cost 1000,1,30 2000,2,45 3000,4,55 6000,5,70 ... (1 Reply)
Discussion started by: Naresh101
1 Replies

9. Shell Programming and Scripting

Compare 2 csv files in ksh and o/p the difference in a new csv file

(say) I have 2 csv files - file1.csv & file2.csv as mentioned below: file1.csv ID,version,cost 1000,1,30 2000,2,40 3000,3,50 4000,4,60 file2.csv ID,version,cost 1000,1,30 2000,2,45 3000,4,55 6000,5,70 The... (7 Replies)
Discussion started by: Naresh101
7 Replies

10. Shell Programming and Scripting

Match columns from two csv files and update field in one of the csv file

Hi, I have a file of csv data, which looks like this: file1: 1AA,LGV_PONCEY_LES_ATHEE,1,\N,1,00020460E1,0,\N,\N,\N,\N,2,00.22335321,0.00466628 2BB,LES_POUGES_ASF,\N,200,200,00006298G1,0,\N,\N,\N,\N,1,00.30887539,0.00050312... (10 Replies)
Discussion started by: djoseph
10 Replies
uhd_cal_tx_iq_balance(1)					   User Commands					  uhd_cal_tx_iq_balance(1)

NAME
uhd_cal_tx_iq_balance - Generate TX IQ Balance Calibration Table DESCRIPTION
The Universal Software Radio Peripheral Hardware Drivers handle calibration information. This application sets up Transmitter calibration for a daughterboard installed on the USRP. Because it also uses the receive side of the daughterboard, this application only handles trans- ceiver daughterboards. USRP Generate TX IQ Balance Calibration Table Allowed options: --help help message --verbose enable some verbose --args arg device address args [default = ""] --tx_wave_freq arg (=507123) Transmit wave frequency in Hz --tx_wave_ampl arg (=0.69999999999999996) Transmit wave amplitude in counts --rx_offset arg (=934400) RX LO offset from the TX LO in Hz --freq_start arg Frequency start in Hz (do not specify for default) --freq_stop arg Frequency stop in Hz (do not specify for default) --freq_step arg (=7300000) Step size for LO sweep in Hz --nsamps arg (=10000) Samples per data capture This application measures leakage between RX and TX on an XCVR daughterboard to self-calibrate. SEE ALSO
uhd_cal_rx_iq_balance(1) uhd_cal_tx_dc_offset(1) UHD
March 2012 uhd_cal_tx_iq_balance(1)
All times are GMT -4. The time now is 04:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy