Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4624598
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:09:08+00:00 2026-05-22T03:09:08+00:00

This may be a toughie so you get bonus points! THIS IS A .TXT

  • 0

This may be a toughie so you get bonus points!

THIS IS A .TXT FILE NOT CSV

I am trying to parse the following comma delimited file into a readable table, and then import everything into my table. Here’s the info I got:

Here’s the “template” of what I am importing from. (This is the first line in the file):

    "Public/Private","Record Manager","Company","Contact","Address 1","Address 2","Address 3","City","State","Zip","Country","ID/Status","Phone","Fax","Home Phone","Mobile Phone","Pager","Salutation","Last Meeting","Last Reach","Last Attempt","Letter Date","Title","Assistant","Last Results","Referred By","User 1","User 2","User 3","User 4","User 5","User 6","User 7","User 8","User 9","User 10","User 11","User 12","User 13","User 14","User 15","Home Address 1","Home Address 2","Home City","Home State","Home Zip","Home Country","Alt Phone","2nd Contact","2nd Title","2nd Phone","3rd Contact","3rd Title","3rd Phone","First Name","Last Name","Phone Ext.","Fax Ext.","Alt Phone Ext.","2nd Phone Ext.","3rd Phone Ext.","Asst. Title","Asst. Phone","Asst. Phone Ext.","Department","Spouse","Record Creator","Owner","2nd Last Reach","3rd Last Reach","Web Site","Ticker Symbol","Create Date","Edit Date","Merge Date","E-mail Login","E-mail System"

Here’s a sample of what someone would normally enter:

    "Public","John Doe”,"Einstein Construction","Bill Gates","3441 State Route 1","","","Somecity","CA","15212","","","724-555-2135","","","","","Jill","","4/18/2011","11/23/2009","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","Bill","Gregor","235","","","","","","","","","","Tom Jones","SuperMart","","","www.website.com","","11/14/2009","4/19/2011","","",""

Here’s the fields I have in the database (MySQL): (obviously without the dollar signs.)

        $rep 
        $date 
        $account 
        $areacode 
        $number 
        $address1 
        $address2 
        $city 
        $state 
        $zip 
        $country 
        $fax 
        $descmaker1 
        $descmaker2 
        $title 
        $email 
        $cvendor 
        $cequipment 
        $leaseexp1 
        $leaseexp2
        $leaseexp3 
        $leaseexp4 
        $leaseexp5
        $leaseexp6 
        $volume
        $notes  
                    $lastchange

Here’s what I need them mapped to.. (My field on right, the files on the left)

                   Record Manager -> $rep 
(record manager i'd rather use our variable which is = $session->userinfo['fullname']
        Create Date -> $date (can the "/" be removed so its MMDDYYYY)
        Company -> $account 
        Phone (can you explode the areacode off?) -> $areacode 
        Phone (and put the number after the areacode here?)-> $number 
        Address 1 -> $address1 
        Address 2 -> $address2 
        City -> $city 
        State -> $state 
        Zip -> $zip 
        Country -> $country 
        Fax -> $fax 
        Salutation -> $descmaker1 
        $descmaker2 
        Title -> $title 
        Email Login -> $email 
                    Edit Date -> $lastchange

What I have right now (that really doesn’t work) is below. It shows the data in a big jumble.

    <?php


$a = file_get_contents( "upload/contacts.txt" );
$a = str_replace( array( "\r\n", "\t") , array( "[NEW*LINE]" , "[tAbul*Ator]" ) , $a);

print "<table border=\"1\">";
foreach( explode( "[NEW*LINE]" , $a ) AS $lines){
echo "<tr>";
foreach( explode( "[tAbul*Ator]" , $lines ) AS $li ) {
echo "<td>";
echo $li ;
}
echo "</tr>";

}

echo "</table>";


?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:09:09+00:00Added an answer on May 22, 2026 at 3:09 am
    $file = fopen('mass-parse.txt', 'r');
    
    while ($line = fgets($file)) {
        list(   $rep, $date, $account, $areacode, $number,
                $address1, $address2, $city, $state, $zip, $country,
                $fax, $descmaker1, $descmaker2, $title, $email,
                $cvendor, $cequipment, $leaseexp1, $le, $leaseexp3, $leaseexp4, $leaseexp5, $leaseexp6,
                $volume, $notes, $lastchange) = explode(',', str_replace('"','',$line));
    
        // do stuff with variables 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a simple question...I'm trying to extract or unzip exe file. I
This may be a stupid question but I have a code with the following
This may be a stupid question, but I'm trying to replicate a customer's OpenLDAP
This may not be an important issue but it bugs me anytime(quite often) I
This may be an easy but I cannot get it figured out. I have
This may be a question that others have seen, but I am trying to
This may or may not be the dumbest question ever. I'm using Restlet. When
This may have been answered elsewhere but I could not find a suitable response.
This may not be possible, but I thought I'd throw it out here: Given
This may seem like a very basic question, since I'm not familiar with jQuery,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.