+ Reply to Thread
Results 1 to 4 of 4

Import txt file with embedded line feeds into Excel as CSV

  1. #1
    Registered User
    Join Date
    05-23-2018
    Location
    US
    MS-Off Ver
    8
    Posts
    2

    Import txt file with embedded line feeds into Excel as CSV

    I want to be able to write a CSV text file than can be imported into Excel.
    The tricky thing is that the encoding of the data of the file is in Shift-JIS.
    If I try to import the file into Excel with a CSV extension, it is imported OK as CSV, but the character encoding for the datis not correct.

    To be able to read the Shift-JIS encoding, I rename the file to end in .txt and select 'Import ... Shift-JIS encoding ... Comma Delimited'.
    Importing this way basically works, but if any of the cells have line feeds in them then those lines are interpreted as the start of a new row in the spreadsheet.

    I found that the problem isn't because of Shift-JIS.
    There seems to be a problem in general with importing text files with cell data that have embedded line feeds.

    For example, if the following data is imported as text, there will be two rows instead of one:

    "11234
    5678",99999

    Any way around this?

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: Import txt file with embedded line feeds into Excel as CSV

    It depends on what ASCII character appears after the 4 - line feeds are 0010, and carriage return/line feeds are 0013. So you could read character by character when importing, reading until you find an 0013 (instead of just an 0010).

    If the end of row character is an 0010 (the same as the internal wrap character), then you could try a macro that reads the file line by line, and checks for an even number of double quote characters, appending the next row if the quotes are not balanced.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    05-23-2018
    Location
    US
    MS-Off Ver
    8
    Posts
    2

    Re: Import txt file with embedded line feeds into Excel as CSV

    Thanks for your reply.

    By "importing", I meant that end users want to be able to open the CSV/Text file into Excel with standard Excel functions.
    Using the Excel Import command on a text file doesn't seem to work.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: Import txt file with embedded line feeds into Excel as CSV

    Using 'standard Excel functions' doesn't work. Either create a macro that does what you want, or change how your txt file is created to make it compatible with standard files.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Import from a text file to excel / problem with line break
    By ddblumenthal in forum Excel General
    Replies: 16
    Last Post: 05-24-2019, 01:53 PM
  2. Replies: 1
    Last Post: 08-03-2016, 11:44 PM
  3. Multiple line invoice that feeds a database on a seperate sheet
    By vicken25 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2014, 07:32 AM
  4. Parsing of line feeds in text file
    By pedron in forum Excel General
    Replies: 1
    Last Post: 02-01-2012, 06:21 PM
  5. multi-line text file import to excel
    By Waxaholic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2006, 03:45 PM
  6. [SOLVED] Can Excel 2002 SP3 automatically import RSS data feeds?
    By Var in forum Excel General
    Replies: 1
    Last Post: 05-10-2005, 06:06 PM
  7. MS Query and Carriage Returns/Line Feeds
    By Gary Brown in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2005, 10:24 AM

Tags for this Thread

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1