![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Oct 2002
Posts: 6,780
|
A tool that can do this?
hey everyone,
say i have 2 files.. ONE TEXT FILE HAS THIS: a b c d e f g other FILE HAS THIS: 1 2 3 4 5 6 7 and i want to merge it, so that its a1 b2 c3 d4 e5 f6 g7 any ideas?
__________________
_________________ I am the best ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Amateur Pimpin
Industry Role:
Join Date: Aug 2004
Location: Orlando, FL
Posts: 13,075
|
Microsoft Access
__________________
Make easy money with Webcams |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Oct 2002
Posts: 6,780
|
tried it.. keep getting space inbetween
(if i use excel and put in diff columns then paste into notepad_
__________________
_________________ I am the best ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Industry Role:
Join Date: Aug 2003
Location: Vegas and Los Angeles
Posts: 2,122
|
It can also be done in MS Excel or Lotus 1-2-3 (IBM).
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Aug 2006
Posts: 268
|
Assuming both files have the same number of lines..
Code:
$f1 = file( "file1" ); $f2 = file( "file2" ); $max = count( $f1_array ); $new = array(); for( $i = 0; $i = $max; $i++ ){ $new[] = $f1[$i] . $f2[$i] . "<br />\n"; } print_r( $new ); |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Nov 2005
Posts: 8,170
|
PHP to the rescue
Code:
$file1 = @file("letters.txt"); $file2 = @file("numbers.txt"); for ($x=1;$x<count($file1);$x++) { $output[] = $file1[x] . $file2[x]; } |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Industry Role:
Join Date: Nov 2005
Posts: 8,170
|
My way is better ... lol
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Join Date: Oct 2002
Posts: 6,780
|
this code will work?
__________________
_________________ I am the best ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Join Date: Aug 2006
Posts: 268
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Join Date: Aug 2006
Posts: 268
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Industry Role:
Join Date: Nov 2005
Posts: 8,170
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 | |
Confirmed User
Join Date: Mar 2006
Location: Montreal
Posts: 415
|
Quote:
![]()
__________________
,|,,(-_-),,|,
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Confirmed User
Join Date: Aug 2002
Location: Kernow
Posts: 2,977
|
Hah me too, the last time I even tried anything like that was as a kid on a Commodore 64, where it was poke this and goto that... I soon gave up but its fun watching the "discussions" between people that do understand it.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
Too lazy to set a custom title
Join Date: Oct 2002
Location: Far far away - as possible
Posts: 14,956
|
Hell.. don't even need a tool to do that. Just use a text editor (eg UltraEdit) in column mode and past the two columns into the one text file and delete all spaces.
__________________
XXX TLD's - Another mosquito to swat. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
Too lazy to set a custom title
Join Date: Nov 2002
Posts: 16,714
|
fukin geeks
__________________
A fast fortune is easy to earn! Just go with a winner! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 | |
Confirmed User
Join Date: Oct 2002
Posts: 6,780
|
Quote:
Array ( ) nothing else
__________________
_________________ I am the best ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 | |
Confirmed User
Join Date: Oct 2006
Posts: 749
|
Quote:
2. Count the array items FIRST, not within your for loop
__________________
Deranged World |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 |
Confirmed User
Join Date: Oct 2002
Posts: 6,780
|
well none of the codes posted here work.... unfortunately
__________________
_________________ I am the best ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,111
|
Using the code posted earlier as a start:
Code:
<?php // bring each file into an array $f1 = file( "testfile1.txt" ); $f2 = file( "testfile2.txt" ); // get len of each array $max = count( $f1 ); $chkmax= count($f2); // use shorter array as maximum value to avoind errors if($chkmax<$max){$max=$chkmax;} // create a new array. You could also open a file to write to instead $new = array(); $fp=fopen('testfile3.txt','w'); // do the loop properly. for( $i = 0; $i <= $max; $i++ ){ // build the new array properly $new[$i] = trim($f1[$i]) . trim($f2[$i]) . "\n"; echo $new[$i] . '<br>'; // if you are writing to a new file you can do it here if you wanted // check to make sure the file opened before writing if ($fp) { // write to the file fwrite($fp,$new[$i]); } } // Print out the rows of the array using print_r or // if you are writing to a new file you could do it here if you wanted to too // print_r($new); if ($fp) { // make sure to close the file if you are writing one fclose($fp); } ?> testfile 1 at http://sigamatic.com/newtest/testfile1.txt testfile 2 at http://sigamatic.com/newtest/testfile2.txt Ouptut file at http://sigamatic.com/newtest/testfile3.txt Have fun ![]()
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#20 |
Chafed.
Join Date: May 2002
Location: Face Down in Pussy
Posts: 18,041
|
That code doesn't actually dump the results, it just puts them into an array.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#21 |
Confirmed User
Join Date: Nov 2003
Location: USA
Posts: 2,862
|
Excel: Put each list in two separate columns (A, B), then in column C use the formula
=concatenate(A1,B1) Copy/paste the formula all the way down and you're done. (you can then copy/paste into notepad without the spaces). --- OR --- Notepad: if you copy/paste the two columns and end up with the spaces, like you mentioned, simple find & replace all instances of " " with "" and the spaces are gone. --- People are making this way too difficult.
__________________
Logan modelperfect [at] gmail.com http://www.modelperfect.com (Proudly hosted at www.webair.com ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#22 |
Confirmed User
Join Date: May 2007
Posts: 1,034
|
try modelperfect's advise on he concatenate...that shoudl certainly work.
|
![]() |
![]() ![]() ![]() ![]() ![]() |