• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[SOLVED] upload CSV ccsid problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] upload CSV ccsid problem

    I am using the VVUPLOAD pgm to upload a CSV file to the as400. When I try to open the CSV file in my RPG pgm to process it only reads junk like i have a character conversion problem. If i do not upload it through valence but instead copy and paste using a windows mapped drive to my system it works correctly? How do i correctly upload the file and it be readable in my rpg? thanks!

    Ryan

  • #2
    if i use the vvupload my CCSID is 37 on the file that is uploaded (this looks like junk when i read it in my rpg program.)
    if i just use a mapped drive and copy to the folder on the IFS then it has a CCSID of 1252 which i can read into my rpg and looks correct.

    Comment


    • #3
      In the RPG just before you do your vvIn_file add a line:

      vvIn.ccsid = 1252;

      Comment


      • #4
        i have added the line to set the ccsid but it still uploaded as CCSID 37.

        Comment


        • #5
          The most likely problem is that the browser itself is identifying the file as binary, in which case the CCSID is ignored by Valence. The browser sends along a "Content-Type" for the file which in your case is likely coming through as octet-stream or something similar. If this is really a text file you're sending then you'll want the browser to identify it as text/plain or text/[anything]. The easiest way to have the browser correctly identify the file on upload is with the file extension. If the extension is ".abc" or something weird then the browser is likely to identify that as binary. However, if you give your file a ".txt" extension it will probably identify that file to Valence as plain/text. What is the file extension?

          Comment


          • #6
            It is a CSV file. You are correct. I changed the extension to .txt and it uploaded and worked correctly. Is there a way i can force the browser to send the CSV as plain/text and not binary without having the user having to remember to change the extension each time he runs the app?
            Last edited by beckhamrryyaann; 07-14-2014, 10:59 AM.

            Comment


            • #7
              Ok I just tested with a CSV file on the latest version of Valence 4.0 and it saved to IFS with a CCSID of 1252 and had a Content-Type of text/csv. I was using Google Chrome. What browser are you using? I'll try to replicate your scenario.

              Comment


              • #8
                I am using windows 8.1 with chrome. This is what the browser is deciding for content type.

                Content-Disposition: form-data; name="file"; filename="room forecast.csv"
                Content-Type: application/vnd.ms-excel

                Comment


                • #9
                  Valence is treating it as binary because of the Content-Type that starts with "application". If you were to change the extension to .txt or change your Windows file association does that work?

                  Comment


                  • #10
                    Yes...if i manually change it to .txt then it runs through with no problems...

                    Comment


                    • #11
                      is there any way i can upload the CSV without having to change the csv extension to txt. the user don't understand why i can't just fix this? :-).

                      Comment


                      • #12
                        Try this:

                        Go into the RPG source for VVUPLOAD and scroll down to what should be line 376.00, currently containing this code:

                        Code:
                        fileTypeIsText = %scan('TEXT':fileType)<>0;
                        Change that line to this:
                        Code:
                        fileTypeIsText = %scan('TEXT':fileType)<>0                           
                                 or %scan('.CSV':vvUtility_convertCase(fileName:toUpper))<>0;
                        Compile that change and see what happens. If that does the trick, we'll go ahead and incorporate it into the next Valence 4 build, as .csv files can probably be universally treated as text instead of binary without causing any issues.

                        -Rob

                        Comment


                        • #13
                          Rob,
                          This worked. Thank you.

                          Comment


                          • #14
                            Great! We'll include that adjustment in the next build then.

                            Comment

                            Working...
                            X