Convert to csv
This commit is contained in:
parent
2955451a5d
commit
dac51051ba
29
cmm_single_processes/convert_to_csv.py
Normal file
29
cmm_single_processes/convert_to_csv.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
from scrub_layer_class import *
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
qgis_path = 'C:/Program Files/QGIS 3.34.1/apps/qgis'
|
||||||
|
cmm_path = \
|
||||||
|
'C:/Users/a_adli/PycharmProjects/cmm_gis_oo/' \
|
||||||
|
'data/output_data/cmm_points_function_vintage_surface/' \
|
||||||
|
'cmm_points_function_vintage_surface.shp'
|
||||||
|
|
||||||
|
cmm = ScrubLayer(qgis_path, cmm_path, 'QC GDTable')
|
||||||
|
|
||||||
|
|
||||||
|
field_names = ['id_provinc', 'mat_18', 'code_util', 'superficie',
|
||||||
|
'nom_etage', 'anne_cnstr', 'supfi_etag', 'typ_btmn', 'nom_logm']
|
||||||
|
|
||||||
|
# Get the indices of the specified fields
|
||||||
|
field_indices = [cmm.layer.fields().indexOf(field) for field in field_names]
|
||||||
|
|
||||||
|
# Extract the attribute values and store them in a list of dictionaries
|
||||||
|
data = []
|
||||||
|
for feature in cmm.layer.getFeatures():
|
||||||
|
attributes = [feature.attributes()[index] for index in field_indices]
|
||||||
|
data.append(dict(zip(field_names, attributes)))
|
||||||
|
|
||||||
|
# Create a DataFrame from the list of dictionaries
|
||||||
|
df = pd.DataFrame(data)
|
||||||
|
|
||||||
|
df.to_csv('../data/csv_files/cmm_points_function_vintage_surface.csv',
|
||||||
|
index=False)
|
0
cmm_single_processes/remove_the_island.py
Normal file
0
cmm_single_processes/remove_the_island.py
Normal file
Loading…
Reference in New Issue
Block a user