Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Don't capitalize field names on csv export

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

    Don't capitalize field names on csv export

    The program I'm importing my csv file into requires the fields to be all lower case. My Alpha Five csv export file contains uppercase field names.

    #2
    Re: Don't capitalize field names on csv export

    Script your own with the file methods.

    <FILE>.WRITE_LINE()

    etc

    Borrowing heavily from the example in the documentation....

    Code:
    dim tbl as P
    tbl = table.open("[COLOR="Red"]c:\a5\a_sports\customer.dbf[/COLOR]")
    flds = strtran(lower(tbl.field_name_get()),crlf(),",")'writes all field names
    ' or flds ="firstname,lastname" 'for example
    file_pointer = file.create("c:\a5\output.txt", FILE_RW_EXCLUSIVE)
    tbl.fetch_first()
    file_pointer.write_line(flds)
    while .NOT. tbl.fetch_eof()
        file_pointer.write_line([COLOR="RoyalBlue"]tbl.first_name - " " + tbl.last_name[/COLOR])
        tbl.fetch_next()
    end while
    file_pointer.flush()
    file_pointer.close()
    tbl.close()
    Change the red portion to your actual table name. Change the blue portion to write the fields you want.
    Last edited by Stan Mathews; 03-09-2009, 12:52 PM.
    There can be only one.

    Comment


      #3
      Re: Don't capitalize field names on csv export

      Thank you very much. I'll give it a try.

      Comment


        #4
        Re: Don't capitalize field names on csv export

        If you only need to write a portion of the records to the csv, tell me about the filter you currently use.

        Also, this line

        file_pointer = file.create("c:\a5\output.txt", FILE_RW_EXCLUSIVE)


        could be

        file_pointer = file.create("c:\a5\output.csv, FILE_RW_EXCLUSIVE) if you like and you can edit the c:\a5\output.
        There can be only one.

        Comment


          #5
          Re: Don't capitalize field names on csv export

          Another possible way that I have used is via the *LINE_REPLACE() function.
          http://support.alphasoftware.com/alphafivehelpv8/Functions/_LINE_REPLACE().htm

          Once you have the field names in lowercase and whatever other format needed, just specify what line you want replaced by it in your csv. This way you don't have to write but one line back to the file.
          Mike
          __________________________________________
          It is only when we forget all our learning that we begin to know.
          It's not what you look at that matters, it's what you see.
          Henry David Thoreau
          __________________________________________



          Comment


            #6
            Re: Don't capitalize field names on csv export

            I have a similar need and have tried Stan and Mike's examples. Not being fluent in xbasic, this frustrating. I wonder why this isn't an option or default in exports?

            Here's the xbasic created by the A5 export operation:
            HTML Code:
            export_filename = "fba_export2.txt"
            a_tbl = table.open("fba_details")
            ON ERROR GOTO ERROR1102201115316500
            
            DIM a5_operation_order as C
            a5_operation_order = "Displayableorderid"
            query.order = a5_operation_order
            DIM a5_operation_filter as C
            a5_operation_filter = "Successful_Upload=.F."
            query.filter = a5_operation_filter
            query.options = "I"
            query.Description = "Temporary Query"
            i_indx = a_tbl.query_create()
            
            export.type = 0
            export.names = .T.
            export.file = export_filename
            export.options = ""
            export.field_sep = "	"
            export.record_sep = "<CR><LF>"
            export.fields = 21
            export.field1 = "merchantfulfillmentorderid"
            export.field2 = "displayableorderid"
            export.field3 = "displayableorderdate"
            export.field4 = "merchantsku"
            export.field5 = "quantity"
            export.field6 = "merchantfulfillmentorderitemid"
            export.field7 = "giftmessage"
            export.field8 = "displayablecomment"
            export.field9 = "perunitdeclaredvalue"
            export.field10 = "displayableordercomment"
            export.field11 = "deliverysla"
            export.field12 = "addressname"
            export.field13 = "addressfieldone"
            export.field14 = "addressfieldtwo"
            export.field15 = "addressfieldthree"
            export.field16 = "addresscity"
            export.field17 = "addresscountrycode"
            export.field18 = "addressstateorregion"
            export.field19 = "addresspostalcode"
            export.field20 = "addressphonenumber"
            export.field21 = "notificationsemail"
            
            a_tbl.export()
            
            
            GOTO CONTINUE1102201115316500
            ERROR1102201115316500:
            ON ERROR GOTO 0
            ui_msg_box("Error","Error running Export Operation"+crlf()+error_text_get())
            END
            CONTINUE1102201115316500:
            a_tbl.close()
            The fields show as lowercase in xbasic but export as uppercase. I need them to be lowercase. If anyone can help me with this, I'd appreciate it.
            Ed Merritt
            UniversalWorkshop.com

            Listen; there's a hell of a good universe next door: let's go.
            e.e. cummings



            Comment


              #7
              Re: Don't capitalize field names on csv export

              ..
              Ed Merritt
              UniversalWorkshop.com

              Listen; there's a hell of a good universe next door: let's go.
              e.e. cummings



              Comment


                #8
                Re: Don't capitalize field names on csv export

                Ed,

                I'd need a sample of the table. One phony record would do.

                Stan
                There can be only one.

                Comment


                  #9
                  Re: Don't capitalize field names on csv export

                  Originally posted by Stan Mathews View Post
                  Ed,
                  I'd need a sample of the table. One phony record would do.
                  Stan
                  Stan, thanks. A zip is attached.
                  Ed Merritt
                  UniversalWorkshop.com

                  Listen; there's a hell of a good universe next door: let's go.
                  e.e. cummings



                  Comment


                    #10
                    Re: Don't capitalize field names on csv export

                    Give this a try instead. Created a function which opens an excel file and makes the first row lowercase. Attachment should be an importable version.

                    Usage would be like.

                    ex_lowcase("c:\test.xls","c:\newlow.xls")

                    Where "c:\test.xls" is the file with uppercase in row 1 and "c:\newlow.xls" is the converted file with lowercase in row 1. (Original file is not changed.)


                    Code:
                    FUNCTION ex_lowcase AS L (excelname AS C, newname AS C )
                    	ex_lowcase = .F.
                    	Dim xlApp as p
                    	dim myCell as c
                    	xlApp = ole.create("Excel.Application")
                    	xlApp.Workbooks.Open(excelname)
                    	'xlApp.Visible = .T. 'comment this line out if you don't want to see Excel
                    	IF xlApp.ActiveWorkbook.ReadOnly
                    		ui_msg_box("Alert","Halting because file is read-only.",UI_OK)
                    		xlapp.DisplayAlerts = .F.
                    		xlApp.Workbooks.Close()
                    		xlapp.DisplayAlerts = .T.
                    		xlApp.Quit()
                    		delete xlApp
                    		exit function
                    	END IF
                    
                    	'establish last row value
                    	lastrow = xlApp.Activecell.SpecialCells("11").Row 
                    	lastcol = xlApp.Activecell.SpecialCells("11").Column
                    	lastcell = xlindx_to_txt(lastcol)+lastrow 
                    	lasthead = xlindx_to_txt(lastcol)+1 
                    	xlApp.Rows("1:1").Select()
                    	xlApp.Selection.Insert(-4121)
                    	for qx = 1 to lastcol
                    		xlApp.Cells(1,qx).Select()
                    		xlApp.ActiveCell.FormulaR1C1 = "=LOWER(R[1]C)"
                    	next qx
                    	xlApp.Range("A1:"+lasthead).Select()
                        xlApp.Application.CutCopyMode = .F.
                        xlApp.Selection.Copy()
                        xlApp.Range("A1").Select()
                        xlApp.Selection.PasteSpecial(-4163,-4142,.F.,.F.)
                        XlApp.Rows("2:2").Select()
                        xlApp.Application.CutCopyMode = .F.
                        xlApp.Selection.Delete(-4162)
                    	xlApp.Range("A1:"+lastcell).Select()
                    	xlapp.DisplayAlerts = .F.
                    	xlApp.ActiveWorkbook.SaveAs(newname,-4143) '33 is a constant for Excel 4.0, dbf4 is 11
                    	xlApp.Workbooks.Close()
                    	xlapp.DisplayAlerts = .T.
                    	xlApp.Quit()
                    	ex_lowcase = .T.
                    END FUNCTION
                    FUNCTION xlindx_to_txt AS C (colnum AS N )
                      If Colnum > 26 Then
                        xlindx_to_txt = Chr(Int((Colnum - 1) / 26) + 64) + Chr((mod((Colnum - 1),26) ) + 65)
                      Else
                        xlindx_to_txt = Chr(Colnum + 64)
                      End If
                    END FUNCTION
                    Last edited by Stan Mathews; 02-11-2011, 05:29 PM. Reason: modified attachment, debug and visible statements
                    There can be only one.

                    Comment


                      #11
                      Re: Don't capitalize field names on csv export

                      Crap! I got wound up with the Excel portion and forgot the original issue.

                      Usage would be

                      ex_lowcase("c:\test.csv","c:\newlow.csv")

                      and the line

                      xlApp.ActiveWorkbook.SaveAs(newname,-4143)

                      should be

                      xlApp.ActiveWorkbook.SaveAs(newname,6) '6 is csv
                      There can be only one.

                      Comment


                        #12
                        Re: Don't capitalize field names on csv export

                        Ed,

                        I think this answers your specific case.

                        Code:
                        dim tbl as P
                        tbl = table.open("fba_details")
                        flds = strtran(lower(tbl.field_name_get()),crlf(),",")'writes all field names
                        file_pointer = file.create("c:\output.txt", FILE_RW_EXCLUSIVE)
                        tbl.fetch_first()
                        file_pointer.write_line(flds)
                        while .NOT. tbl.fetch_eof()
                        	towrite = alltrim(tbl.Merchantfu)+","
                        	towrite = towrite + alltrim(tbl.Displayabl)+","
                        	towrite = towrite + alltrim(tbl.Displayab0)+","
                        	towrite = towrite + alltrim(tbl.Merchantsk)+","
                        	towrite = towrite + alltrim(str(tbl.Quantity,8))+","
                        	towrite = towrite + alltrim(tbl.Merchantf0)+","
                        	towrite = towrite + alltrim(tbl.Giftmessag)+","
                        	towrite = towrite + alltrim(tbl.Displayab1)+","
                        	towrite = towrite + alltrim(str(tbl.Perunitdec,8,2))+","
                        	towrite = towrite + alltrim(tbl.Displayab2)+","
                        	towrite = towrite + alltrim(tbl.Deliverysl)+","
                        	towrite = towrite + alltrim(tbl.Addressnam)+","
                        	towrite = towrite + alltrim(tbl.Addressfie)+","
                        	towrite = towrite + alltrim(tbl.Addressfi0)+","
                        	towrite = towrite + alltrim(tbl.Addressfi1)+","
                        	towrite = towrite + alltrim(tbl.Addresscit)+","
                        	towrite = towrite + alltrim(tbl.Addresscou)+","
                        	towrite = towrite + alltrim(tbl.Addresssta)+","
                        	towrite = towrite + alltrim(tbl.Addresspos)+","
                        	towrite = towrite + alltrim(tbl.Addresspho)+","
                        	towrite = towrite + alltrim(tbl.Notificati)+","
                        	towrite = towrite + alltrim(convert_type(tbl.Successful,"C"))+","
                        	towrite = towrite + alltrim(tbl.Orderdetai)
                            file_pointer.write_line(towrite)
                            tbl.fetch_next()
                        end while
                        file_pointer.flush()
                        file_pointer.close()
                        tbl.close()
                        There can be only one.

                        Comment


                          #13
                          Re: Don't capitalize field names on csv export

                          Steve, thanks for your help. The file that is created contains order to be uploaded to Amazon.com. What I've found out is the field names must be exactly the same as the Excel template they supply. In other words, all lowercase or uppercase won't work.
                          A fieldname MerchantFulfillmentOrderID must have caps just as I've written here.

                          So, I'm back to square one. I'm assuming the solution is to use an array in place of
                          Code:
                          flds = strtran(lower(tbl.field_name_get()),crlf(),",")'writes all field names
                          Is using an array the route I should be going?
                          Ed Merritt
                          UniversalWorkshop.com

                          Listen; there's a hell of a good universe next door: let's go.
                          e.e. cummings



                          Comment


                            #14
                            Re: Don't capitalize field names on csv export

                            Originally posted by Ed Merritt View Post
                            Is using an array the route I should be going?
                            No. Just create the header line as you want it.

                            flds = "MerchantFulfillmentOrderID"+","+..............
                            There can be only one.

                            Comment

                            Working...
                            X