Comma-delimited file format?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl Mercier

    Comma-delimited file format?

    Hi!

    I have written a little class in .NET to convert a DataTable or a
    dataView to a comma-delimited text file. This file eventually gets
    imported in Excel or Word.

    Everything works great, I handled commas and quotes and Excel reads my
    files correctly. I have one little problem, though... If a field in the
    datatable has a carriage return in it, it gets written to the text file
    (of course) and Excel things it's the start of a new record.

    Is there a special character I can replace the CR with so Excel knows
    that it is not a new record but a CR inside a field?

    Thank you!

    Carl

  • William Leung

    #2
    Re: Comma-delimited file format?

    Carl,
    Try replacing CRLF (hex OD OA) with just the line feed character (hex 0A).

    William

    "Carl Mercier" <info@carl-mercier.nojunkp lease.com> wrote in message
    news:%234Lojeei DHA.3700@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > Hi!
    >
    > I have written a little class in .NET to convert a DataTable or a
    > dataView to a comma-delimited text file. This file eventually gets
    > imported in Excel or Word.
    >
    > Everything works great, I handled commas and quotes and Excel reads my
    > files correctly. I have one little problem, though... If a field in the
    > datatable has a carriage return in it, it gets written to the text file
    > (of course) and Excel things it's the start of a new record.
    >
    > Is there a special character I can replace the CR with so Excel knows
    > that it is not a new record but a CR inside a field?
    >
    > Thank you!
    >
    > Carl
    >[/color]


    Comment

    • Carl Mercier

      #3
      Re: Comma-delimited file format?

      William,

      It didn't work unfortunately. Do you have any other idea?

      Thanks!

      Carl




      William Leung wrote:[color=blue]
      > Carl,
      > Try replacing CRLF (hex OD OA) with just the line feed character (hex 0A).
      >
      > William
      >
      > "Carl Mercier" <info@carl-mercier.nojunkp lease.com> wrote in message
      > news:%234Lojeei DHA.3700@TK2MSF TNGP11.phx.gbl. ..
      >[color=green]
      >>Hi!
      >>
      >>I have written a little class in .NET to convert a DataTable or a
      >>dataView to a comma-delimited text file. This file eventually gets
      >>imported in Excel or Word.
      >>
      >>Everything works great, I handled commas and quotes and Excel reads my
      >>files correctly. I have one little problem, though... If a field in the
      >>datatable has a carriage return in it, it gets written to the text file
      >>(of course) and Excel things it's the start of a new record.
      >>
      >>Is there a special character I can replace the CR with so Excel knows
      >>that it is not a new record but a CR inside a field?
      >>
      >>Thank you!
      >>
      >>Carl
      >>[/color]
      >
      >
      >[/color]

      Comment

      • William Leung

        #4
        Re: Comma-delimited file format?

        Carl,

        I'm using Excel from office XP and it did work for me. However, I would
        expect it should work for all version of Excel. What you can do to get the
        format of the file correct is to examine a CSV file that Excel creates
        itself. Create an Excel sheet with a cell that has a carriage return in it,
        (To do this use the ALT+Enter key combo while editing) and then in the SAVE
        AS dialog box change the file type to CSV. Examine the file using a hex
        editor.

        Hope this helps,

        William.

        "Carl Mercier" <info@carl-mercier.nojunkp lease.com> wrote in message
        news:O5ZueUpiDH A.2536@TK2MSFTN GP10.phx.gbl...[color=blue]
        > William,
        >
        > It didn't work unfortunately. Do you have any other idea?
        >
        > Thanks!
        >
        > Carl
        >
        >
        >
        >
        > William Leung wrote:[color=green]
        > > Carl,
        > > Try replacing CRLF (hex OD OA) with just the line feed character (hex[/color][/color]
        0A).[color=blue][color=green]
        > >
        > > William
        > >
        > > "Carl Mercier" <info@carl-mercier.nojunkp lease.com> wrote in message
        > > news:%234Lojeei DHA.3700@TK2MSF TNGP11.phx.gbl. ..
        > >[color=darkred]
        > >>Hi!
        > >>
        > >>I have written a little class in .NET to convert a DataTable or a
        > >>dataView to a comma-delimited text file. This file eventually gets
        > >>imported in Excel or Word.
        > >>
        > >>Everything works great, I handled commas and quotes and Excel reads my
        > >>files correctly. I have one little problem, though... If a field in the
        > >>datatable has a carriage return in it, it gets written to the text file
        > >>(of course) and Excel things it's the start of a new record.
        > >>
        > >>Is there a special character I can replace the CR with so Excel knows
        > >>that it is not a new record but a CR inside a field?
        > >>
        > >>Thank you!
        > >>
        > >>Carl
        > >>[/color]
        > >
        > >
        > >[/color]
        >[/color]


        Comment

        • Cindy Winegarden

          #5
          Re: Comma-delimited file format?

          In news:%23bTIrCti DHA.1672@TK2MSF TNGP09.phx.gbl,
          William Leung <NOwkleungSPAM@ optonline.net> posted:[color=blue]
          > ... Create an Excel sheet with a cell that has a
          > carriage return in it, (To do this use the ALT+Enter key combo while
          > editing) and then in the SAVE AS dialog box change the file type to
          > CSV. Examine the file using a hex editor.[/color]

          My strings were separated by OA, just as you suggested.

          --
          Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
          cindy.winegarde n@mvps.org, www.cindywinegarden.com


          Comment

          Working...