multiple-columns

know the number of columns from text file, separated by space or tab

自闭症网瘾萝莉.ら 提交于 2019-12-02 02:54:16
I need to know the number of columns from a text file with floats. I've made like this to know the number of lines: inFile.open(pathV); // checks if file opened if(inFile.fail()) { cout << "error loading .txt file for reading" << endl; return; } // Count the number of lines int NUMlines = 0; while(inFile.peek() != EOF){ getline(inFile, dummyLine); NUMlines++; } inFile.close(); cout << NUMlines-3 << endl; // The file has 3 lines at the beginning that I don't read A line of the .txt : 189.53 58.867 74.254 72.931 80.354 The number of values can vary from file to file but not on the same file.

How to print columns one after the other in bash?

邮差的信 提交于 2019-12-02 01:47:18
Is there any better methods to print two or more columns into one column, for example input.file AAA 111 BBB 222 CCC 333 output: AAA BBB CCC 111 222 333 I can only think of: cut -f1 input.file >output.file;cut -f2 input.file >>output.file But it's not good if there are many columns, or when I want to pipe the output to other commands like sort . Any other suggestions? Thank you very much! With awk awk '{if(maxc<NF)maxc=NF; for(i=1;i<=NF;i++){(a[i]!=""?a[i]=a[i]RS$i:a[i]=$i)} } END{ for(i=1;i<=maxc;i++)print a[i] }' input.file You can use a GNU awk array of arrays to store all the data and

How to transform a key/value string into separate columns?

十年热恋 提交于 2019-12-02 01:32:15
问题 I've got a data.frame with key/value string column containing information about features and their values for a set of users. Something like this: data<-data.frame(id=1:3,statid=c("s003e","s093u","s085t"),str=c("a:1,7:2","a:1,c:4","a:3,b:5,c:33")) data # id statid str # 1 1 s003e a:1,7:2 # 2 2 s093u a:1,c:4 # 3 3 s085t a:3,b:5,c:33 What I'm trying to do is to create a data.frame containing column for every feature. Like this: data_after<-data.frame(id=1:3,statid=c("s003e","s093u","s085t"), a

How to replace fetched values with another column while querying with SQL Server 2008 R2

蹲街弑〆低调 提交于 2019-12-02 00:20:00
问题 Alright let me explain my question with example We have 1 table This table contains Id Name Number Now example 1 House 4 2 Hospital 3 3 Airport 1 4 Station 2 Now when fetching as select * from table I want to replace third column number values with that number representing Name So example of fetching 1 House Station 2 Hospital Airport 3 Airport House 4 Station Hospital How can i do this ? thank you 回答1: select t1.id, t1.name, t2.name as name2 from your_table t1 left join your_table t2 on t1

How do I create a row of justified elements with fluid spacing using CSS?

蹲街弑〆低调 提交于 2019-12-01 23:27:13
How do I create a row of block elements with auto widths using text-align:justify , display: flex , column-count and/or other CSS properties? Use the following components: A text-align:justify container for the row An inline-block container for each column An inline-block placeholder with width:100% to stretch the inside ` /*Row container is justified*/ #container { width: 100%; text-align: justify; } /*Column container and placeholder are inline-block*/ object, span { display: inline-block; } /*Placeholder is stretched to enforce shrink-wrapping*/ span { width: 100%; } <!--row--> <div id=

How to replace fetched values with another column while querying with SQL Server 2008 R2

为君一笑 提交于 2019-12-01 21:47:56
Alright let me explain my question with example We have 1 table This table contains Id Name Number Now example 1 House 4 2 Hospital 3 3 Airport 1 4 Station 2 Now when fetching as select * from table I want to replace third column number values with that number representing Name So example of fetching 1 House Station 2 Hospital Airport 3 Airport House 4 Station Hospital How can i do this ? thank you select t1.id, t1.name, t2.name as name2 from your_table t1 left join your_table t2 on t1.number = t2.id You can join the same table twice to replace the number with the name . The on contidion in

Convert single column file into multiple columns

微笑、不失礼 提交于 2019-12-01 20:16:53
Basically, I want to convert one column file into multiple column file specified by number of rows. I do not want to reinvent the wheel. I want to make sure if there is a unix command / or standard way of doing this before writing a custom script. For example, let's say I have the following file: $cat input.txt tom jack kim bart foo bar I want to turn this into 3 row file $ cat input.txt | my_script --every=3 --delimiter=tab tom bart jack foo kim bar or 2 row file with the different delimter: $ cat input.txt | my_script --every=2 --delimiter=, tom,kim,foo jack,bart,bar With awk awk -v row=2 '

How to keep bootstrap columns of same size so that they snap correctly?

£可爱£侵袭症+ 提交于 2019-12-01 20:15:48
I'm building a simple site with bootstrap columns, but I would like for them to stay with the same height, since as of right now, if the last column in the row is short in height, the next one gets placed below it instead of on the next row to the left. How could I do this? .col-xs-3 { border: 1px solid red; } <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <div class="container"> <div class="row "> <div class="col-xs-3">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut nisi, quia. Nobis, quam, provident. Quam quidem reiciendis, aliquid

R data.table multi column recode/sub-assign [duplicate]

大兔子大兔子 提交于 2019-12-01 20:02:38
This question already has an answer here: Fastest way to replace NAs in a large data.table 8 answers Let DT be a data.table: DT<-data.table(V1=sample(10), V2=sample(10), ... V9=sample(10),) Is there a better/simpler method to do multicolumn recode/sub-assign like this: DT[V1==1 | V1==7,V1:=NA] DT[V2==1 | V2==7,V2:=NA] DT[V3==1 | V3==7,V3:=NA] DT[V4==1 | V4==7,V4:=NA] DT[V5==1 | V5==7,V5:=NA] DT[V6==1 | V6==7,V6:=NA] DT[V7==1 | V7==7,V7:=NA] DT[V8==1 | V8==7,V8:=NA] DT[V9==1 | V9==7,V9:=NA] Variable names are completely arbitrary and do not necessarily have numbers. Many columns (Vx:Vx) and one

iphone: how make Multiple Columns in UITableView [duplicate]

佐手、 提交于 2019-12-01 19:47:06
Possible Duplicate: How to display multiple columns in a UITableView? I have multiple rows and columns of data. But iPhone UITableView contains only single column and multiple rows. How do I display my multi column data following Apple's Human Interface Guidelines? Any ideas? Paras Joshi Use GridView for your this requirement, see this bellow links for the Demos and Tutorial ... Grid-View-in-IPhone-using-UITableView-1665 GMGridView UIGridView I use this below code to display Time-Table with multiple columns, Some code for Example .. - (UITableViewCell *)tableView:(UITableView *)tableView