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.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-08-2007, 01:57 PM   #1
xxweekxx
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
xxweekxx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 01:59 PM   #2
CIVMatt
Amateur Pimpin
 
CIVMatt's Avatar
 
Industry Role:
Join Date: Aug 2004
Location: Orlando, FL
Posts: 13,075
Microsoft Access
__________________
Make easy money with Webcams
CIVMatt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:13 PM   #3
xxweekxx
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
xxweekxx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:13 PM   #4
NemesisEnforcer
Confirmed User
 
NemesisEnforcer's Avatar
 
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).
NemesisEnforcer is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:17 PM   #5
Zoose
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 );
Zoose is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:18 PM   #6
fallenmuffin
Confirmed User
 
fallenmuffin's Avatar
 
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];
}
fallenmuffin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:18 PM   #7
fallenmuffin
Confirmed User
 
fallenmuffin's Avatar
 
Industry Role:
Join Date: Nov 2005
Posts: 8,170
My way is better ... lol
fallenmuffin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:20 PM   #8
xxweekxx
Confirmed User
 
Join Date: Oct 2002
Posts: 6,780
this code will work?
__________________
_________________
I am the best
xxweekxx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:20 PM   #9
Zoose
Confirmed User
 
Join Date: Aug 2006
Posts: 268
Quote:
Originally Posted by fallenmuffin View Post
My way is better ... lol
Gonna recount em' each iteration? :p
Zoose is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:23 PM   #10
Zoose
Confirmed User
 
Join Date: Aug 2006
Posts: 268
Quote:
Originally Posted by xxweekxx View Post
this code will work?
Yes, just upload the code above in a .php file and the text files in the same directory and it'll spit out the values concatenated.
Zoose is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:25 PM   #11
fallenmuffin
Confirmed User
 
fallenmuffin's Avatar
 
Industry Role:
Join Date: Nov 2005
Posts: 8,170
Quote:
Originally Posted by Zoose View Post
Gonna recount em' each iteration? :p
No more so then you counting the array and writing it a variable.
fallenmuffin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 06:13 PM   #12
themachinelavene
Confirmed User
 
Join Date: Mar 2006
Location: Montreal
Posts: 415
Quote:
Originally Posted by fallenmuffin View Post
No more so then you counting the array and writing it a variable.
lol...i luv it when programmers fight
__________________
,|,,(-_-),,|,
themachinelavene is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 06:24 PM   #13
Lee
Confirmed User
 
Join Date: Aug 2002
Location: Kernow
Posts: 2,977
Quote:
Originally Posted by themachinelavene View Post
lol...i luv it when programmers fight
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.
Lee is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 06:30 PM   #14
Webby
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.
Webby is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 06:30 PM   #15
p1mpdogg
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!
p1mpdogg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 07:21 AM   #16
xxweekxx
Confirmed User
 
Join Date: Oct 2002
Posts: 6,780
Quote:
Originally Posted by Zoose View Post
Yes, just upload the code above in a .php file and the text files in the same directory and it'll spit out the values concatenated.
doesnt work.. i just get

Array ( )

nothing else
__________________
_________________
I am the best
xxweekxx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 07:31 AM   #17
schneemann
Confirmed User
 
Join Date: Oct 2006
Posts: 749
Quote:
Originally Posted by fallenmuffin View Post
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];
}
1. error suppression sucks.
2. Count the array items FIRST, not within your for loop
__________________
Deranged World
schneemann is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 07:44 AM   #18
xxweekxx
Confirmed User
 
Join Date: Oct 2002
Posts: 6,780
well none of the codes posted here work.... unfortunately
__________________
_________________
I am the best
xxweekxx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 10:29 AM   #19
sarettah
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);
}

?>
Working model at http://sigamatic.com/newtest/testit.php

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!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 11:04 AM   #20
gornyhuy
Chafed.
 
gornyhuy's Avatar
 
Join Date: May 2002
Location: Face Down in Pussy
Posts: 18,041
Quote:
Originally Posted by xxweekxx View Post
doesnt work.. i just get

Array ( )

nothing else
That code doesn't actually dump the results, it just puts them into an array.
__________________

icq:159548293
gornyhuy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 11:44 AM   #21
ModelPerfect
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 )
ModelPerfect is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 11:48 AM   #22
royaljelly2
Confirmed User
 
Join Date: May 2007
Posts: 1,034
try modelperfect's advise on he concatenate...that shoudl certainly work.
royaljelly2 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.