Sponsored Content
Top Forums Programming Concatenate string from text file Post 302843964 by siya@ on Friday 16th of August 2013 12:00:54 AM
Old 08-16-2013
Concatenate string from text file

Hi

mY files paths are defined as :


Code:
//sbase = 'D:\data\sample_AMC\fasta_files\';
sbase2 = 'D:\data\sample_AMC\fasta_files\results\';
snameprefix = 'orig_ind';
snameprefix3 = 'results_ind';

...
const string filname = sbase + snameprefix  + snamesuffix;
const string resultsname_ = sbase2 + snameprefix3  + snamesuffix;

This concatenation works perfectly fine when i have to manually defines the samplesnames


However now I have 98 such samples names to work with.This implies I have to keep updating my sbase and sbase2 98 times.

If my sample name changes from sample_AMC to sampleABC_123 then I have to update the path manuallyto
Code:
sbase = 'D:\data\sampleABC_123\fasta_files\';
sbase2 = 'D:\data\sampleABC_123\fasta_files\results\';


In order to make it easier,I saved all my 98 samplename entries in a text file.


text file looks like this
sample_AMC
sampleABC_123
sampeBMC
sampleQWE

Is there a way I could read string entries line by line from a text file using c++ and concatenate it to sbase and sbase2?

Last edited by siya@; 08-16-2013 at 01:10 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

appending string to text file based on search string

Hi, I need to append string "Hi" to the beginning of the lines containing some specific string. How can I achieve that? Please help. Malay (1 Reply)
Discussion started by: malaymaru
1 Replies

2. Shell Programming and Scripting

How to concatenate a string in every row data of a file??

Please look into the example. My source file is like, 00,57,3,2008-07-24 06:30:06 10,1,8025171,"1M00",17907023,2008-07-23 18:16:58 10,2,8025171,"1M00",17907023,2008-07-23 18:17:01 99,184 What should i do if i want output like... hello,00,57,3,2008-07-24 06:30:06... (7 Replies)
Discussion started by: pkumar3
7 Replies

3. UNIX for Dummies Questions & Answers

Concatenate a string to a variable

Hello All, How to concatenate a string to a variable in a script I'm having a file which is consisting of data and i need to extract the first line of the file and append it to a string. /tmp/samp.list containg 60000 I like to concatenate it with a string (SS_) grep -w SS_$(head -1... (1 Reply)
Discussion started by: nkamalkishore
1 Replies

4. Shell Programming and Scripting

Search for string in a file, extract two another strings and concatenate to a variable

I have a file with <suit:run date="Trump Tue 06/19/2012 11:41 AM EDT" machine="garg-ln" build="19921" level="beta" release="6.1.5" os="Linux"> Need to find word "build" then extract build number, which is 19921 also release number, which is 6.1.5 then concatenate them to one variable as... (6 Replies)
Discussion started by: garg
6 Replies

5. Shell Programming and Scripting

Search a string in a text file and add another string at the particular position of a line

I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies

6. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

7. Shell Programming and Scripting

How to concatenate 2-columns by 2 -columns for a text file?

Hello, I want to concatenate 2-columns by 2-columns separated by colon. How can I do so? For example, I have a text file containing 6 columns separated by tab. I want to concatenate column 1 and 2; column 3 and 4; column 5 and 6, respectively, and put a colon in between. input file: 1 0 0 1... (10 Replies)
Discussion started by: huiyee1
10 Replies

8. Shell Programming and Scripting

Concatenate text file

I have a text file in the below format: chr1 10002681 10002826 LZIC chr1 10002980 10003083 NMNAT1 chr1 10003485 10003573 NMNAT1 chr1 100111430 100111918 PALMD chr1 100127874 100127955 PALMD chr1 100133197 100133322 PALMD chr1 100152231 100152346 PALMD chr1 100152485 100152519 PALMD... (8 Replies)
Discussion started by: cmccabe
8 Replies

9. UNIX for Beginners Questions & Answers

Search a string and display its location on the entire string and make a text file

I want to search a small string in a large string and find the locations of the string. For this I used grep "string" -ob <file name where the large string is stored>. Now this gives me the locations of that string. Now how do I store these locations in a text file. Please use CODE tags as... (7 Replies)
Discussion started by: ANKIT ROY
7 Replies

10. UNIX for Beginners Questions & Answers

Concatenate a string and number and compare that with another string in awk script

I have below code inside my awk script if ( $0 ~ /SVC IN:/ ) { svc_in=substr( $0,23 , 3); if (msg_start == 1 && msg_end == 0) { msg_arr=$0; } } else if ( $0 ~ /^SVC OUT:/ ) { svc_out=substr( $0, 9, 3); if (msg_start == 1 && msg_end == 0) ... (6 Replies)
Discussion started by: bhagya123
6 Replies
Graphics::Primitive::Insets(3pm)			User Contributed Perl Documentation			  Graphics::Primitive::Insets(3pm)

NAME
Graphics::Primitive::Insets - Space between things DESCRIPTION
Graphics::Primitive::Insets represents the amount of space that surrounds something. This object can be used to represent either padding or margins (in the CSS sense, one being inside the bounding box, the other being outside) SYNOPSIS
use Graphics::Primitive::Insets; my $insets = Graphics::Primitive::Insets->new({ top => 5, bottom => 5, left => 5, right => 5 }); METHODS
Constructor new Creates a new Graphics::Primitive::Insets. Instance Methods as_array Return these insets as an array in the form of top, right, bottom and left. bottom Set/Get the inset from the bottom. equal_to Determine if these Insets are equal to another. left Set/Get the inset from the left. right Set/Get the inset from the right. top Set/Get the inset from the top. zero Sets all the insets (top, left, bottom, right) to 0. AUTHOR
Cory Watson, "<gphat@cpan.org>" SEE ALSO
perl(1) COPYRIGHT &; LICENSE Copyright 2008-2010 by Cory G Watson. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2010-08-21 Graphics::Primitive::Insets(3pm)
All times are GMT -4. The time now is 12:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy