Application crashes with data layers #58527
Labels
Bug
Either a bug report, or a bug fix. Let's hope for the latter!
Crash/Data Corruption
Feedback
Waiting on the submitter for answers
PyQGIS
Related to the PyQGIS API
stale
Uh oh! Seems this work is abandoned, and the PR is about to close.
What is the bug or the crash?
I'm totally newbie with QGis.
I want to draw in a layer several polygons. To do this, I load the data in the layer from a csv file. This csv file has a total amount of 65.000 rows and a weight of 109MB. The load of information in the layer works fine.
The problem is when I try to get this information and process it.
the 65,000 records in the csv file but when I read the information the application crashes.
Steps to reproduce the issue
If I try to process the total amount in a batch processing.
`
layer = iface.activeLayer()
features = layer.getFeatures()
batch_size = 5000
batch = []
def process_batch(batch):
for feat in batch:
id_pts = feat["id_"]
pts_perim = feat["points"]
print(id_pts)
#print(pts_perim)
print("Batch processing succesfully!!!")
for i, feat in enumerate(features):
batch.append(feat)
print(f"Feature {i} added to the list")
if i % batch_size == 0:
process_batch(batch)
batch = []
`
The process usually to crash in this line of code
for i, feat in enumerate(features):
And it's not possible to advance because the application crashes. ¡¡¡In other computer happens the same!!!
However, If I try to get access to the information loading this infromation over a dataframe, I can run through the entire dataframe and print the value of the variable id_ on the screen.!!!
Here is my code:
`
import pandas as pd
pd.options.display.max_columns = None
df = pd.read_csv('F:\Proyectos\QGis\cent_cont_P8_xd3_id.csv')
df["points"] = df["points"].astype("string")
#df["coords"] = df.points.split(";")
df["coords"] = 0
for index, row in df.iterrows():
df["coords"][index] = df["points"][index]
df["coords"][index] = df["points"][index].split(";")
df["coords"][index] = [tuple(map(float, cadena.strip('()').split(','))) for cadena in df["coords"][index]]
batch_size = 5000
batch = []
for index, row in df.iterrows():
print(row["id_"])
print("Proceso finalizado!!!")
`
This code works for me from time to time. Because the same code with the same data sometimes works fine and another the application crashes. But in another computer the application crashes always!!! How is that possible? This other computer has installed the version 3.23 of QGis.
I am desperate, because I have learned how to create a polygon on the layer, but now I need to create a polygon based on each of the registers of the csv file, around 65.000 polygons.
Versions
<style type="text/css"> p, li { white-space: pre-wrap; } </style>Complementos activos de Python
db_manager
0.1.20
grassprovider
2.12.99
MetaSearch
0.3.6
processing
2.12.99
Supported QGIS version
New profile
Additional context
No response
The text was updated successfully, but these errors were encountered: