+ Reply to Thread
Results 1 to 11 of 11

How to convert one cell by column using one delimiter and by row using another delimiter?

  1. #1
    Forum Contributor
    Join Date
    04-03-2009
    Location
    Anchorage, Alaska, USA
    MS-Off Ver
    Office 365
    Posts
    113

    How to convert one cell by column using one delimiter and by row using another delimiter?

    I have a text (or CSV) file containing GPS data from Google Earth. Put simply it's x,y,0 x,y,0 x,y,0 x,y,0 (I dont know what the zero is for, only interested in the x,y). But you see how it is? Comma = new column; space = new row. So I want 3 columns and however many rows this generates.

    So
    Row 1, Col A = -149.9206228808253 Col B = 61.26921241825455 Col C = 0
    Row 2, Col A = -149.9216448308434 Col B = etc....

    But I do not know how to do that. Excel has so many options I must be missing something I've never used before.

    -149.9206228808253,61.26921241825455,0 -149.9216448308434,61.26911504137816,0 -149.9219176334521,61.2721902519847,0 -149.9222498967939,61.27260312784155,0 -149.9229091587051,61.27335465317403,0 -149.9238683706947,61.27424459126385,0 -149.9243037353575,61.27518193661559,0 -149.9245010561375,61.27675773493462,0 -149.9245355620001,61.2775616101568,0

    There's a sample of the data - it imports into cell a1 as one long string. commas = new column; space = new row. Where would I look to learn the answer?

    Thank you.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    It imports as one long string as it's not officially a CSV file.
    CSV - comma separated variable. The commas indicate where to separate the data.

    But after each 0 is a space which is clearly indicating the end of data and the start of new data.
    CSV files dont use space as a separator, therefore it's not a CSV file and Excel is interpreting it all as a string.

    You prob need VBA to do this properly, unfortunately I dont have time.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    You CAN do this with a mix of Global replacements, Text to Columns, Copy and Transpose, and Text to Columns. That's the good news. The bad news is that, for some reason (probably too many digits after the decimal place), it loses the last digit. I'm guessing that is important .

    So, as Special-K has said, think it would need VBA. BUT, you might suffer with the same issues.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    you could try inserting a basic Power Query script along lines of attached (assumes .txt)

    Please Login or Register  to view this content.
    to modify for your own use, with Queries and Connections panel, right click - Edit - then update the file path in Source step by clicking on the first Settings icon, and Browsing to the location

    edit: per TMS, removed Change Type as you will need to persist as Text given XL limits on significant digits
    Attached Files Attached Files
    Last edited by XLent; 09-16-2021 at 06:39 AM.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,192

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    This will Split string

    Please Login or Register  to view this content.

    but has already been pointed, data will be TEXT

    See Sheet2
    Attached Files Attached Files

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    Please note that John Topley's VBA routine is much quicker than the manual approach I outlined earlier. However, it still loses the least significant digit. For example, -149.9206228808253,61.26921241825455 splits as -149.920622880825 and 61.2692124182545. I ask again, is that an issue?

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,192

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    The TEXT split is OK (all the digits) BUT, as TMS says, converting to numeric loses the least significant digit.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    Slight modification to JT's code. Definitely text output BUT it does retain all the digits.

    Please Login or Register  to view this content.

  9. #9
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    Data in A1

    B1
    =TRIM(MID(SUBSTITUTE(FILTERXML("<x><m>"&SUBSTITUTE(A1,",0 ","</m><m>")&"</m></x>","//m"),",",REPT(" ",40)),{1,41},40))

  10. #10
    Forum Contributor
    Join Date
    04-03-2009
    Location
    Anchorage, Alaska, USA
    MS-Off Ver
    Office 365
    Posts
    113

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    Wow! People.
    This is so cool. I'll look on my home system as this is a personal project. But some thoughts...
    • Losing the last digit(s) dont really matter. I think by the time we're at the last few decimal positions we're talking the width of the flea's bahonkus, so I'm not worried.
    • TMS: I was thinking of Rubik's Cube'ing the data but so much of that Ribbon I do not know about. So I agree with what I think you were suggesting - I can do it via ttc, transpose, etc, but should I? It's funny how we can so easily see what to do, but to explain the steps to a program is really hard. It's a good perspective on how fast and deep our minds can work.
    • XLENT: Power Query - I like your robust solution and will look at it! I def need to learn more about PQ.
    • Bo_Ry: Elegant! I have no idea what I'm looking at after the third nesting - I'll check it out. Thanks.
    • JohnTopley: I did not know about VBA Split. It makes total sense. Nice addition by TMS too.

    Like I said I'll look this weekend and give reps etc. I cant wait.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: How to convert one cell by column using one delimiter and by row using another delimit

    You're welcome.

    Have a good weekend.

    @JohnTopley:
    but has already been pointed, data will be TEXT
    Actually, I think pushing the array out to the worksheet appears to output numeric data. Hence the tiny mod to your code.



    @akedm:
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. [SOLVED] Regex - Split string at fixed delimiter but keep "Groups" with same delimiter together
    By bakerman2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-27-2021, 02:22 AM
  2. Split Column by delimiter
    By ypurcaro in forum Excel General
    Replies: 5
    Last Post: 08-30-2020, 06:46 PM
  3. [SOLVED] Split a column using comma delimiter
    By brent_milne in forum Excel General
    Replies: 5
    Last Post: 10-09-2019, 01:45 PM
  4. [SOLVED] VBA- Convert txt file into excel using delimiter and filter
    By ksky88 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-28-2017, 07:18 AM
  5. Convert CSV to XLSX with semicolon as delimiter
    By JordtenBulte in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2017, 10:46 AM
  6. How to split a column at first delimiter only
    By Jonathan78 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-07-2016, 08:32 AM
  7. [SOLVED] Take cell value spit on delimiter SORT the ensuing array then Join on delimiter post back
    By capson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2016, 03:54 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