read a shapefile projection file delimiters

Windows specific forum
ehowington
Enthusiast
Enthusiast
Posts: 117
Joined: Sat Sep 12, 2009 3:06 pm

read a shapefile projection file delimiters

Post by ehowington »

any thoughts on how to separate the information within this file

file data withing the lines below:
--------------------------------------------------------------------------------------------------------------------------
PROJCS["NAD_1927_StatePlane_Ohio_South_FIPS_3402",GEOGCS["GCS_North_American_1927",DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",2000000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-82.5],PARAMETER["Standard_Parallel_1",38.73333333333333],PARAMETER["Standard_Parallel_2",40.03333333333333],PARAMETER["Latitude_Of_Origin",38.0],UNIT["Foot_US",0.3048006096012192]]
--------------------------------------------------------------------------------------------------------------------------

example of data that need to be striped out
PROJCS["NAD_1927_StatePlane_Ohio_South_FIPS_3402",

i need info within the "" along with the header PROJCS for example
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: read a shapefile projection file delimiters

Post by IdeasVacuum »

Your one example is not enough for us to understand what the other separated datasets should be. Show the whole line split-up as required.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
skywalk
Addict
Addict
Posts: 4242
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: read a shapefile projection file delimiters

Post by skywalk »

Search the forum for a Split() function and load the file into a string or array per line break.
Then parse the resulting string repeatedly until you have your desired fields and values.
This assumes you know the common pattern or delimiter.

It would help if you describe exactly your 'FROM' & 'TO'.
I see the 'FROM', but only a portion of the 'TO'.
Are the '-------' lines included in the file as separators?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Ramihyn_
Enthusiast
Enthusiast
Posts: 314
Joined: Fri Feb 24, 2006 9:40 am

Re: read a shapefile projection file delimiters

Post by Ramihyn_ »

Doesn't it work by simply using the "," as seperator?

So you use "Countstring" to find how many comma seperated fields there are. Then look through them with the "Stringfield" command. On the resulting string, you use "Stringfield" again with "[" as seperator to get the leading token ("PROJCS") and "Stringfield" with " as seperator to get the value ("NAD_1927_StatePlane_Ohio_South_FIPS_3402").

Obviously if there are commas inside the value fields too, you need to handle that case.
ehowington
Enthusiast
Enthusiast
Posts: 117
Joined: Sat Sep 12, 2009 3:06 pm

Re: read a shapefile projection file delimiters

Post by ehowington »

yeah that's kinda the issues im having problems trying to figure out.


Ramihyn_ wrote:Doesn't it work by simply using the "," as seperator?

So you use "Countstring" to find how many comma seperated fields there are. Then look through them with the "Stringfield" command. On the resulting string, you use "Stringfield" again with "[" as seperator to get the leading token ("PROJCS") and "Stringfield" with " as seperator to get the value ("NAD_1927_StatePlane_Ohio_South_FIPS_3402").

Obviously if there are commas inside the value fields too, you need to handle that case.
Ramihyn_
Enthusiast
Enthusiast
Posts: 314
Joined: Fri Feb 24, 2006 9:40 am

Re: read a shapefile projection file delimiters

Post by Ramihyn_ »

ehowington wrote:yeah that's kinda the issues im having problems trying to figure out.
Simple rule - quotation marks come in pairs, if you have a string which contains an uneven number of quotation marks, you are inside a string-field and need to apply a fix (like injecting a comma and appending the next field). This is a simplified way of doing it, a more correct way would be to make a proper loop which seperates the comma fields manually and uses a running counter of "quotation marks". Splitting at commas then only happens if the quotation mark counter is even.
Post Reply