SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    python and mySQL

    Hi,

    I am trying to import a CSV file but my code breaks around the 'r\n' can any one help me work out how to resolve this?
    Code Python:
    cursor.execute ("LOAD DATA INFILE '/tmp/trains.csv' INTO TABLE trains FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n'IGNORE 1 LINES;")

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,437
    Mentioned
    45 Post(s)
    Tagged
    13 Thread(s)
    Hi,

    Try doubling up on the backslashes:
    Code:
    LINES TERMINATED BY '\\r\\n'

  3. #3
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers that looks like it would work just need to solve an issue with the columns now

  4. #4
    SitePoint Member
    Join Date
    Jul 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can someone help me??? Is the node.js part od python or its separate program??? I will start learn node,js thats the future for sure...

  5. #5
    SitePoint Addict
    Join Date
    Jul 2014
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by xvinez View Post
    Can someone help me??? Is the node.js part od python or its separate program??? I will start learn node,js thats the future for sure...
    If you dont know what node.js even is, I'm not sure how you can be certain "its the future" and something you want to learn.
    To answer your question, it has nothing to do with Python.

  6. #6
    SitePoint Member
    Join Date
    Jul 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    NVm....i will find it and let u know...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •