How Do I Convert TXT To CSV Format

Discussion in 'Programming' started by highbids, Dec 26, 2008.

  1. #1
    Hi,

    I need to convert a text file with a list of keywords like
    "new york dentist" into a csv format any simple way to do it.
     
    highbids, Dec 26, 2008 IP
  2. Yesideez

    Yesideez Peon

    Messages:
    196
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Does it only contain keywords?

    One thing you can do is to read the file in using file()
    $arrFile=file('keywords.txt');
    PHP:
    That reads the file into an array called $arrFile - each line is stored as an element
    $arrFile[0] is line 1
    $arrFile[1] is line 2
    $arrFile[2] is line 3 and so-on...

    To separate the lines up into separate keywords use this:
    foreach ($arrFile as $strLine) {
      $arrKeywords=explode(" ",$strLine);
      //do what you want with the keywords here
    }
    PHP:
    The line starting // is where you do whatever you want with your keywords - store them in a MySQL database etc.

    What that code does is go through each line in the file splitting into another array this time called:
    $arrKeywords[0] is "new"
    $arrKeywords[1] is "york"
    $arrKeywords[2] is "dentist" and so-on

    If you don't want "new york" split into separate keywords then this is where you will have problems. Either run a search and replace on the TXT file beforehand replacing all spaces with commas and then removing those commas to which words you want to remain together or handle them after you've handled the keywords.
     
    Yesideez, Dec 27, 2008 IP
  3. highbids

    highbids Well-Known Member

    Messages:
    214
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    I converted it to .csv format, the problem started with a software program that
    does Geo searches for keywords by putting in a seed keyword and then picking a
    state like New York which returns over 5K of phrases.

    It will then return keywords like Norfolk dentist, the software program allows me to export
    it with commas around the phrase or brackets or just as phrases.

    Sense this program just spits out long tail keywords & not the searches etc.
    I then have to find out the searches & the competing pages for each phrase.

    I own "Keyword Research Pro" which is like Keyword Elite, but the search
    count back with N/A

    I've heard of people running PPC campaigns with thousands of keywords
    at AdWords & was wondering what program they using .
     
    highbids, Dec 27, 2008 IP