Skip to main content
deleted 43 characters in body; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Joining CSV file to Shp file using ogr2ogr and python?

I am having problems with the code below i.e. parsing the SQL string in python. I keep getting an error. I am joining a CSV file called lookup_scales.csv to a shp file called RC_CATALOGUE_GRANTED. I am running the ogr2ogr command within python and using os.system to call it. It doesn't like the 'lookup_scales.csv' part i.e the apostrophes around it. BTW I was able to run the command successfully within a DOS window so not sure why is fails in the os.system call?

I am grateful for any help to resolve. Also the shp file and csv file actually sit in different directories and would like to specify those locations in the ogr2ogr command. At the moment to get the command to work in DOS I have had to put the shp file and csv file in the directory I am running the python code I have.

Code:

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED.*, lookup_scales.* from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

NB. Above based on the Join CSV file to shapefile thread on here

Joining CSV file to Shp file using ogr2ogr and python

I am having problems with the code below i.e. parsing the SQL string in python. I keep getting an error. I am joining a CSV file called lookup_scales.csv to a shp file called RC_CATALOGUE_GRANTED. I am running the ogr2ogr command within python and using os.system to call it. It doesn't like the 'lookup_scales.csv' part i.e the apostrophes around it. BTW I was able to run the command successfully within a DOS window so not sure why is fails in the os.system call?

I am grateful for any help to resolve. Also the shp file and csv file actually sit in different directories and would like to specify those locations in the ogr2ogr command. At the moment to get the command to work in DOS I have had to put the shp file and csv file in the directory I am running the python code I have.

Code:

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED.*, lookup_scales.* from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

NB. Above based on the Join CSV file to shapefile thread on here

Joining CSV file to Shp file using ogr2ogr and python?

I am having problems with the code below i.e. parsing the SQL string in python. I keep getting an error. I am joining a CSV file called lookup_scales.csv to a shp file called RC_CATALOGUE_GRANTED. I am running the ogr2ogr command within python and using os.system to call it. It doesn't like the 'lookup_scales.csv' part i.e the apostrophes around it. BTW I was able to run the command successfully within a DOS window so not sure why is fails in the os.system call?

Also the shp file and csv file actually sit in different directories and would like to specify those locations in the ogr2ogr command. At the moment to get the command to work in DOS I have had to put the shp file and csv file in the directory I am running the python code I have.

Code:

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED.*, lookup_scales.* from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

Above based on the Join CSV file to shapefile thread on here

Bumped by Community user
improved formatting
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

I am having problems with the code below i.e. parsing the SQL string in python. I keep getting an error. I am joining a CSV file called lookup_scales.csvlookup_scales.csv to a shp file called RC_CATALOGUE_GRANTEDRC_CATALOGUE_GRANTED. I am running the ogr2ogr command within python and using os.systemos.system to call it. It doesn't like the 'lookup_scales.csv''lookup_scales.csv' part i.e the apostrophes around it. BTW I was able to run the command successfully within a dosDOS window so not sure why is fails in the os.systemos.system call?

I am grateful for any help to resolve. Also the shp file and csv file actually sit in different directories and would like to specify those locations in the ogr2ogrogr2ogr command. At the moment to get the command to work in dosDOS I have had to put the shp file and csv file in the directory I am running the python code I have.

Code:

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED.*, lookup_scales.* from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

NB. Above based on the Join CSV file to shapefile thread on here

I am having problems with the code below i.e. parsing the SQL string in python. I keep getting an error. I am joining a CSV file called lookup_scales.csv to a shp file called RC_CATALOGUE_GRANTED. I am running the ogr2ogr command within python and using os.system to call it. It doesn't like the 'lookup_scales.csv' part i.e the apostrophes around it. BTW I was able to run the command successfully within a dos window so not sure why is fails in the os.system call?

I am grateful for any help to resolve. Also the shp file and csv file actually sit in different directories and would like to specify those locations in the ogr2ogr command. At the moment to get the command to work in dos I have had to put the shp file and csv file in the directory I am running the python code I have

Code:

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED.*, lookup_scales.* from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

NB. Above based on the Join CSV file to shapefile thread on here

I am having problems with the code below i.e. parsing the SQL string in python. I keep getting an error. I am joining a CSV file called lookup_scales.csv to a shp file called RC_CATALOGUE_GRANTED. I am running the ogr2ogr command within python and using os.system to call it. It doesn't like the 'lookup_scales.csv' part i.e the apostrophes around it. BTW I was able to run the command successfully within a DOS window so not sure why is fails in the os.system call?

I am grateful for any help to resolve. Also the shp file and csv file actually sit in different directories and would like to specify those locations in the ogr2ogr command. At the moment to get the command to work in DOS I have had to put the shp file and csv file in the directory I am running the python code I have.

Code:

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED.*, lookup_scales.* from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

NB. Above based on the Join CSV file to shapefile thread on here

added 4 characters in body
Source Link
ahmadhanb
  • 41.4k
  • 5
  • 54
  • 109

I am having problems with the code below i.e. parsing the SQL string in python. I keep getting an error. I am joining a CSV file called lookup_scales.csv to a shp file called RC_CATALOGUE_GRANTED. I am running the ogr2ogr command within python and using os.system to call it. It doesn't like the 'lookup_scales.csv' part i.e the apostrophes around it. BTW I was able to run the command successfully within a dos window so not sure why is fails in the os.system call?

I am grateful for any help to resolve. Also the shp file and csv file actually sit in different directories and would like to specify those locations in the ogr2ogr command. At the moment to get the command to work in dos I have had to put the shp file and csv file in the directory I am running the python code I have

Code:

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED., lookup_scales. from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED.*, lookup_scales.* from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

NB. Above based on the Join CSV file to shapefile thread on here

I am having problems with the code below i.e. parsing the SQL string in python. I keep getting an error. I am joining a CSV file called lookup_scales.csv to a shp file called RC_CATALOGUE_GRANTED. I am running the ogr2ogr command within python and using os.system to call it. It doesn't like the 'lookup_scales.csv' part i.e the apostrophes around it. BTW I was able to run the command successfully within a dos window so not sure why is fails in the os.system call?

I am grateful for any help to resolve. Also the shp file and csv file actually sit in different directories and would like to specify those locations in the ogr2ogr command. At the moment to get the command to work in dos I have had to put the shp file and csv file in the directory I am running the python code I have

Code:

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED., lookup_scales. from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

NB. Above based on the Join CSV file to shapefile thread on here

I am having problems with the code below i.e. parsing the SQL string in python. I keep getting an error. I am joining a CSV file called lookup_scales.csv to a shp file called RC_CATALOGUE_GRANTED. I am running the ogr2ogr command within python and using os.system to call it. It doesn't like the 'lookup_scales.csv' part i.e the apostrophes around it. BTW I was able to run the command successfully within a dos window so not sure why is fails in the os.system call?

I am grateful for any help to resolve. Also the shp file and csv file actually sit in different directories and would like to specify those locations in the ogr2ogr command. At the moment to get the command to work in dos I have had to put the shp file and csv file in the directory I am running the python code I have

Code:

os.system('ogr2ogr -sql "select RC_CATALOGUE_GRANTED.*, lookup_scales.* from RC_CATALOGUE_GRANTED left join 'lookup_scales.csv'.lookup_scales on RC_CATALOGUE_GRANTED.SCALE = lookup_scales.Scale" shape_join.shp RC_CATALOGUE_GRANTED.shp')

NB. Above based on the Join CSV file to shapefile thread on here

Source Link
daveb
  • 139
  • 4
Loading