Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. csv file problem

csv file problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
15 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Eugen Podsypalnikov

    Please compare the return values of UINT uiReadBytes = chopChart.Read(..); at the first an secon running and post them here :)

    virtual void BeHappy() = 0;

    U Offline
    U Offline
    User 589870
    wrote on last edited by
    #3

    in both cases uireadbytes contains 0.

    E 1 Reply Last reply
    0
    • U User 589870

      in both cases uireadbytes contains 0.

      E Offline
      E Offline
      Eugen Podsypalnikov
      wrote on last edited by
      #4

      Try it :) :

      {
      ...
      CFile cFile;
      if (cFile.Open(strFileName, CFile::modeRead)) {
      BYTE byBuffer[1024] = {0};
      UINT uiReadBytes = cFile.Read(byBuffer, sizeof(byBuffer));
      CString cszMessage;
      cszMessage.Format(_T("File: %s:\r\nCount of read bytes = %u"),
      strFileName, uiReadBytes);
      AfxMessageBox(cszMessage);
      cFile.Close();
      }
      ...
      }

      virtual void BeHappy() = 0;

      U 1 Reply Last reply
      0
      • E Eugen Podsypalnikov

        Try it :) :

        {
        ...
        CFile cFile;
        if (cFile.Open(strFileName, CFile::modeRead)) {
        BYTE byBuffer[1024] = {0};
        UINT uiReadBytes = cFile.Read(byBuffer, sizeof(byBuffer));
        CString cszMessage;
        cszMessage.Format(_T("File: %s:\r\nCount of read bytes = %u"),
        strFileName, uiReadBytes);
        AfxMessageBox(cszMessage);
        cFile.Close();
        }
        ...
        }

        virtual void BeHappy() = 0;

        U Offline
        U Offline
        User 589870
        wrote on last edited by
        #5

        actually on saving file at close of application it is inserting end of file after every character.this is actually the problem.

        E 1 Reply Last reply
        0
        • U User 589870

          actually on saving file at close of application it is inserting end of file after every character.this is actually the problem.

          E Offline
          E Offline
          Eugen Podsypalnikov
          wrote on last edited by
          #6

          Please answer, what have you seen at the message boxes ? :)

          virtual void BeHappy() = 0;

          U 1 Reply Last reply
          0
          • E Eugen Podsypalnikov

            Please answer, what have you seen at the message boxes ? :)

            virtual void BeHappy() = 0;

            U Offline
            U Offline
            User 589870
            wrote on last edited by
            #7

            in both cases it is showing count 1024 in messageboxes..my qus is that where is my code inserting EOF after every character?

            E 1 Reply Last reply
            0
            • U User 589870

              in both cases it is showing count 1024 in messageboxes..my qus is that where is my code inserting EOF after every character?

              E Offline
              E Offline
              Eugen Podsypalnikov
              wrote on last edited by
              #8

              Good, the file can be read in the both cases :) What is your next step (wish) please ? :) Would you like to read and write an UNICODE or ANSI csv-file ? :)

              virtual void BeHappy() = 0;

              U 1 Reply Last reply
              0
              • E Eugen Podsypalnikov

                Good, the file can be read in the both cases :) What is your next step (wish) please ? :) Would you like to read and write an UNICODE or ANSI csv-file ? :)

                virtual void BeHappy() = 0;

                U Offline
                U Offline
                User 589870
                wrote on last edited by
                #9

                why my code is inserting EOF after evry character on saving file.where my code is wrong?

                E 1 Reply Last reply
                0
                • U User 589870

                  why my code is inserting EOF after evry character on saving file.where my code is wrong?

                  E Offline
                  E Offline
                  Eugen Podsypalnikov
                  wrote on last edited by
                  #10

                  When your project is configured as UNICODE project the output will be performed by two bytes per character... Would you like to see your output in ANSI ? :)

                  virtual void BeHappy() = 0;

                  U 1 Reply Last reply
                  0
                  • E Eugen Podsypalnikov

                    When your project is configured as UNICODE project the output will be performed by two bytes per character... Would you like to see your output in ANSI ? :)

                    virtual void BeHappy() = 0;

                    U Offline
                    U Offline
                    User 589870
                    wrote on last edited by
                    #11

                    yes?but i want to keep the project as unicode

                    E 1 Reply Last reply
                    0
                    • U User 589870

                      yes?but i want to keep the project as unicode

                      E Offline
                      E Offline
                      Eugen Podsypalnikov
                      wrote on last edited by
                      #12

                      :) چرا که نه؟ Just convert your string to ANSI sequence:

                      #include <AtlConv.h>
                      ...
                      {
                      ...
                      USES_CONVERSION;
                      LPSTR lpszANSI = T2A(cszOut);
                      cOutFile.Write(lpszANSI, strlen(lpszANSI));
                      ...
                      }

                      virtual void BeHappy() = 0;

                      U 1 Reply Last reply
                      0
                      • E Eugen Podsypalnikov

                        :) چرا که نه؟ Just convert your string to ANSI sequence:

                        #include <AtlConv.h>
                        ...
                        {
                        ...
                        USES_CONVERSION;
                        LPSTR lpszANSI = T2A(cszOut);
                        cOutFile.Write(lpszANSI, strlen(lpszANSI));
                        ...
                        }

                        virtual void BeHappy() = 0;

                        U Offline
                        U Offline
                        User 589870
                        wrote on last edited by
                        #13

                        thanx a lot Eugen Podsypalnikov that was what the problem was actually it was inserting extra byte.thanx nw it is working fine after converting to ansi. Regards

                        E 1 Reply Last reply
                        0
                        • U User 589870

                          thanx a lot Eugen Podsypalnikov that was what the problem was actually it was inserting extra byte.thanx nw it is working fine after converting to ansi. Regards

                          E Offline
                          E Offline
                          Eugen Podsypalnikov
                          wrote on last edited by
                          #14

                          You are welcome ! (sometimes I do read and write UNICODE csv-files, you could it too, when it will be needed once :) )

                          virtual void BeHappy() = 0;

                          U 1 Reply Last reply
                          0
                          • E Eugen Podsypalnikov

                            You are welcome ! (sometimes I do read and write UNICODE csv-files, you could it too, when it will be needed once :) )

                            virtual void BeHappy() = 0;

                            U Offline
                            U Offline
                            User 589870
                            wrote on last edited by
                            #15

                            yeah thanx ;)

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups