+ Reply to Thread
Results 1 to 11 of 11

How to extract text from blocks defined by “$begin” and “$end” ?

  1. #1
    Registered User
    Join Date
    04-30-2009
    Location
    tokyo
    MS-Off Ver
    Excel 2016
    Posts
    43

    How to extract text from blocks defined by “$begin” and “$end” ?

    Hello

    I have this ASCII file that I need to extract and organize data from it. I need to locate the text between "$begin" and "$end", split it and lay it out in a table

    $begin pec
    simple('conductivity', 1.0E30)
    ModTime=1028307964
    $end pec
    .
    .
    .
    $begin nickel
    simple('conductivity', 14500000)
    simple('permeability', 600)
    simple('thermal_conductivity',90)
    simple('mass_density',8900)
    simple('specific_heat',444)
    simple('youngs_modulus',210000000000)
    simple('poissons_ratio',0.35)
    simple('thermal_expansion_coeffcient',1.3e-005)
    ModTime=1132068240
    $end nickel

    I would like to create a table that looks like
    name conductivity permeability thermal_conductivity
    pec 1.00E+30 … ….
    nickel 14500000 600 90

    any suggestions?

    Thanks

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    Can you provide us with a sample file with enough non-sensitive data to prove the concept (I'd suggest about 4-5 metals' worth).
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    04-30-2009
    Location
    tokyo
    MS-Off Ver
    Excel 2016
    Posts
    43

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    here are the first 42 line of 2340. Is there a way to upload a file?

    $begin '$base_index$'
    $begin 'properties'
    all_levels=000000000000
    time(year=000000002016, month=000000000002, day=000000000024, hour=000000000015, min=000000000053, sec=000000000014)
    version=000000000000
    $end 'properties'
    $begin '$base_index$'
    $index$(pos=000000065904, lin=000000002618, lvl=000000000000)
    $end '$base_index$'
    $end '$base_index$'
    $begin vacuum
    ('permittivity', 1)
    ModTime=1028307964
    $end vacuum
    $begin pec
    ('conductivity', 1.0E30)
    ModTime=1028307964
    $end pec
    $begin 'perfect conductor'
    ('conductivity', 1.0E30)
    ModTime=1028307964
    $end 'perfect conductor'
    $begin steel_stainless
    ('conductivity', 1100000)
    ('thermal_conductivity',13.8)
    ('mass_density',8055)
    ('specific_heat',480)
    ('youngs_modulus',195000000000)
    ('poissons_ratio',0.3)
    ('thermal_expansion_coeffcient',1.08e-005)
    ModTime=1132068240
    $end steel_stainless
    $begin zinc
    ('conductivity', 16700000)
    ('thermal_conductivity',115.5)
    ('mass_density',7140)
    ('specific_heat',389)
    ('youngs_modulus',115000000000)
    ('poissons_ratio',0.33)
    ('thermal_expansion_coeffcient',6.35e-005)
    ModTime=1132068240
    $end zinc

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    To upload a file click on the Go Advanced button and scroll down to manage attachments. Click on that link and your will get a dialog box to select the file and upload it.

  5. #5
    Registered User
    Join Date
    04-30-2009
    Location
    tokyo
    MS-Off Ver
    Excel 2016
    Posts
    43

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    please see attached the full file
    Attached Files Attached Files

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    Here is a list of the things I think you want parsed out. Please review and correct. Thanks.

    element
    conductivity
    mass_density
    permittivity
    poissons_ratio
    specific_heat
    thermal_conductivity
    thermal_expansion_coeffcient
    youngs_modulus
    ModTime

  7. #7
    Registered User
    Join Date
    04-30-2009
    Location
    tokyo
    MS-Off Ver
    Excel 2016
    Posts
    43

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    yes, this is correct

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    This is how I read your problem.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-30-2009
    Location
    tokyo
    MS-Off Ver
    Excel 2016
    Posts
    43

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    Thanks, that would do it. Do you have any reference for the codes used in the line that includes the ".Pattern=..."?

  10. #10
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    This may be more difficult than originally envisioned. It seems there are "nested" begin-end combinations leading to consecutive cells with $begin and $end.

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: How to extract text from blocks defined by “$begin” and “$end” ?

    Google with the key words like

    VBA Regular Expression meta character etc.

    And try this one for the shortest block.
    Please Login or Register  to view this content.

+ 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. Extract title blocks from Draftsight/ Acad
    By ids in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-16-2024, 01:44 AM
  2. Text Filter-begin With... (multiple Begin Withs?)
    By hariexcel1987 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-02-2013, 02:12 PM
  3. [SOLVED] Split String in 3 Blocks of #s, Extract each Block to copy on specific Cell
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-19-2013, 12:14 AM
  4. Using macros to identify blocks of data and summarise those blocks
    By gophbeav in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2012, 04:35 AM
  5. Text Filter Begin with macro_Excel attached
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2011, 03:22 PM
  6. Text Filter-Begin with... (multiple begin withs?)
    By flyflipper in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-16-2010, 06:29 PM
  7. [SOLVED] Serial Numbers that begin with Text
    By KRC in forum Excel General
    Replies: 4
    Last Post: 06-27-2006, 12:45 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