+ Reply to Thread
Results 1 to 12 of 12

modifying csv values

Hybrid View

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    10

    modifying csv values

    Hi, I need to import lots of price tables to web shop and luckily it accepts csv files.
    I have all the price tables in excel format and every value is in its own cell. (multiple rows also)
    My problem is that in csv the prices should be between double quotes and separated with comma. (like "60","70","80","90","100",)

    I have not managed to get that kind of output yet, how could I get this kind of result when saving csv from excel 2010?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: modifying csv values

    Hi,

    Is it an option to concatenate all the columns together along with double quotes and commas into a single column of text values. Then export the single column as a csv.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: modifying csv values

    Thank you for this.
    Would you be kind enough to let me know how exactly to do this in excel, or guide me the right way.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: modifying csv values

    Hi

    e.g. with values in A1:C1

    Formula: copy to clipboard
    =""""&A1&""","""&B1&""","""&C1&""""

  5. #5
    Registered User
    Join Date
    04-14-2014
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: modifying csv values

    Sorry, still struggling here, if I could offer examples:

    This is the price table that I have, row 1 is product width and column A is product height, so prices are for dimensional products.

    And this is the way that the shop will accept the csv files:

    Any help converting these csvīs would be greatly appreciated!

    Edit: Didn't realize that I can also attach files, please find this now updated.
    Attached Files Attached Files
    Last edited by Jonathan More; 04-17-2014 at 11:33 AM.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: modifying csv values

    Hi,

    Please upload the files to the forum. Most of us prefer not to use third party file depositories.

  7. #7
    Registered User
    Join Date
    04-14-2014
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: modifying csv values

    Files are now attached to previous message, thanks for letting me know of this option.

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: modifying csv values

    Hi,

    Have you tried the following

    1. Select A1:M12
    2. File SaveAs and select the CSV(MS-DOS(*.csv) file type
    3. OK
    4. Accept the warning message about the file type does not support workbooks that contain multiple sheets and answer OK
    5. Accept the warning that the file may contain features not compatible with CSV(MS-DOS) and answer Yes

  9. #9
    Registered User
    Join Date
    04-14-2014
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: modifying csv values

    Hi, sure I have tried that way, but it separates values with semicolon and the shop dont accept that.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: modifying csv values

    Hi,

    That's presumably because in your Windows Control Panel for Regional Settings you have identified the ; character as the list separator. Temporarily change this to a , and then do the Save As csv operation.

  11. #11
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    604

    Re: modifying csv values

    Hi Jonathan,

    This macro should do it for you.

    1) Put all CSV file paths in "Column A"
    2) Click the button
    3) Macro opens each CSV file and put quotes around every cell, then saves with a "_" after file name.

    Sub tester()
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
        
        Dim ms1 As String
        Dim ms2 As String
        
        Dim c1 As Range
        Dim r1 As Range
        Set r1 = Range("A1:A100")   'Put all CSV file paths in this range...
        
        For Each c1 In r1   'Loop each CSV workbook
            If c1.Value <> "" Then
            
                Workbooks.Open Filename:=c1.Value
                ms1 = ms1 & vbCrLf & c1.Value
                
                Dim cell As Range
                Dim rng As Range
                Set rng = Range("A1:Z1000")     '<--- Change if more cells in CSV books...
                
                For Each cell In rng            'For each cell in CSV Range... put quotes around...
                    If cell.Value <> "" Then
                        cell.Value = Chr(34) & cell.Value & Chr(34)
                    End If
                Next cell
                
                Dim file_path As String
                Dim new_path As String
                 
                file_path = Application.ActiveWorkbook.FullName
                new_path = Left(file_path, Len(file_path) - 4) & "_.csv"
                ActiveWorkbook.SaveAs Filename:=new_path
                ActiveWindow.Close
                
                ms2 = ms2 & vbCrLf & new_path
            End If
        Next c1
        
        Application.DisplayAlerts = True
        Application.ScreenUpdating = True
        
        
        MsgBox "Original files:" & ms1 & vbCrLf & vbCrLf & "Modified files:" & ms2
    End Sub
    Attached Images Attached Images
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    04-14-2014
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: modifying csv values

    Thank you for this great effort, but still something is missing. It didn't place individual values between double quotes, but the whole row. Also the semi colons didnt transfer to comma.

    You can find the file I wanted to transfer and the result with this script attached.
    Attached Files Attached 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. Replies: 0
    Last Post: 06-19-2012, 06:22 AM
  2. modifying a macro that marks up a row of values
    By focodelic in forum Excel General
    Replies: 3
    Last Post: 12-17-2010, 12:33 AM
  3. Purpose of Operation:=xlNone and modifying values before pasting
    By xyz123 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-01-2008, 07:27 AM
  4. [SOLVED] Modifying links without updating values..
    By GOHOINC in forum Excel General
    Replies: 3
    Last Post: 05-31-2006, 04:00 PM
  5. Modifying a Formula To display only Unique Values
    By carl in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-16-2005, 04:06 PM

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