Skip to content

Instantly share code, notes, and snippets.

@LimaGuilherme
LimaGuilherme / project-structure
Last active October 10, 2018 00:36
A example of basic structure.
+--- geo_processing
| __init__
| elastic_search_connection.py
| config.py
| country.py
@LimaGuilherme
LimaGuilherme / country.py
Last active October 10, 2018 01:25
first_version_of_index_country_polygons
def index_country_polygons(path_to_file):
schema = {
'geometry': 'Polygon',
}
with fiona.open('{}'.format(path_to_file), 'r',
'ESRI Shapefile', schema) as polygon_feature:
for geometry in polygon_feature:
polygon = shape(geometry['geometry'])
country = geometry['properties']['NM_MUNICIP']
import elasticsearch
import elasticsearch_dsl
from elasticsearch_dsl.connections import connections, get_connection
import config as config_module
config = config_module.get_config()
f = open('workfile' ,'r', encoding='utf-8')
file_content = open('dados/some_sb.csv', encoding='utf-8', mode='w')
new_content = '1,someContent'
file_content.write(new_content)
f = open('workfile' ,'r')
f.readline()
f.readlines()
f.read()
file_content = open('dados/some_sb.csv', encoding='utf-8', mode='w')
new_content = '1,someContent'
file_content.write(new_content)
f = open('workfile' ,'w')
new_content = 'someContent'
f.write(new_content)
f = open('workfile' ,'w')
new_content = 'someContent'
f.write(new_content)
f.seek(0)
line = f.readline()
print line
>> someContent
f = open('workfile' ,'w')
new_content = 'someContent'
f.write(new_content)
f.flush()
...