On QGis, I have a series of points that I want to transform into a path, with the qgis tool "from points to path". these points, in their attributes table, have a column called Time, expressed like this e.g. 140370.908. another called Image expressed like this e.g. VAL_ISARCO_01\LadybugPanoramas\T20241007145532891.jpg. before the extension .jpeg the filename seems to express a date and time fraction

This fields are usually constant sometimes, instead, they differ by a tot in its sequentiality. e.g. 140370.908 up to Point 140371.812. when i encounter this, with a gap between two valors kinda high, the tool "from points to path" generates me an artifactual connection line. It is because of this gap, between the two values (of 2127 for this layer). what I would like to do, in the presence of the gap, is to make 140370.908 for example the last vertex of a part of the path and 140371.812 the first beginning vertex of a new line. just to avoid the creation of artifacts. or TO AVOID THIS UNWANTED CONCATENTION. the points-to-path tool allows regex input maybe it can be done that way. i dont want to manully reve all the unwanted lines obviously as it could take me forever. Be careful.
a. Calculating Time Differences
Here's a summary of the time differences (gaps) between consecutive entries:

Entry	Time		Next Time	Gap (Seconds)		Observation
1		140132.891	140142.215	~9.32499999999325	Significantly Large Gap
2		140142.215	140143.215	1.0					Normal
3		140143.215	140144.108	~0.893				Slightly Smaller Gap
4		140144.108	140145.108	1.0					Normal
5		140145.108	140146.307	~1.199				Slightly Larger Gap
6		140146.307	140147.414	~1.107				Normal
...	...	...	...	...
100+	140758.213	140758.614	~0.401				Consistent Gap
...	...	...	...	...
Last Entry	141106.616	141107.016	~0.4				Consistent Gap
Note: The table above summarizes a subset of the entire dataset for brevity.
(I want this calcolous to be done and prompted on the script itself when analysing the shape file)
Could it be also calculating the total kms of the new shape created?
Here's my script
```
import geopandas as gpd
import pandas as pd
from shapely.geometry import LineString
import os
import sys

def get_input(prompt, default=None, cast_type=str):
    while True:
        if default is not None:
            user_input = input(f"{prompt} [{default}]: ")
            if user_input == "":
                user_input = default
        else:
            user_input = input(f"{prompt}: ")
        try:
            return cast_type(user_input)
        except ValueError:
            print(f"Invalid input. Please enter a value of type {cast_type.__name__}.")

def main():
    print("=== Points to Paths Conversion ===\n")
    
    # Step 1: Input Shapefile Path
    input_shapefile = input("Enter the path to your input points shapefile (.shp): ").strip('"').strip("'")
    if not os.path.isfile(input_shapefile):
        print("Error: The specified shapefile does not exist.")
        sys.exit(1)
    
    # Step 2: Load Shapefile
    try:
        gdf = gpd.read_file(input_shapefile)
    except Exception as e:
        print(f"Error loading shapefile: {e}")
        sys.exit(1)
    
    # Step 3: Display Available Fields
    fields = list(gdf.columns)
    print("\nAvailable Fields:")
    for i, field in enumerate(fields, 1):
        print(f"{i}. {field}")
    
    # Step 4: Select Time Field
    time_field = ""
    while True:
        time_field_input = get_input("\nEnter the name of the Time field from the above list", default=None)
        if time_field_input in fields:
            # Check if field is numeric
            if pd.api.types.is_numeric_dtype(gdf[time_field_input]):
                time_field = time_field_input
                break
            else:
                print(f"Error: The field '{time_field_input}' is not numeric. Please choose a numeric field.")
        else:
            print("Error: Field not found. Please enter a valid field name.")
    
    # Step 5: Enter Gap Threshold
    gap_threshold = get_input("\nEnter the gap threshold (same units as Time)", default=5.0, cast_type=float)
    
    # Step 6: Enter Group Field Name
    default_group_field = "PathID"
    group_field = input(f"\nEnter the name for the group field [default: {default_group_field}]: ").strip()
    if group_field == "":
        group_field = default_group_field
    
    # Step 7: Add Group Field if it doesn't exist
    if group_field not in gdf.columns:
        gdf[group_field] = 0
    
    # Step 8: Sort by Time
    gdf_sorted = gdf.sort_values(by=time_field).reset_index(drop=True)
    
    # Step 9: Assign PathIDs
    current_group = 1
    previous_time = None
    path_ids = []
    
    for idx, row in gdf_sorted.iterrows():
        current_time = row[time_field]
        if pd.isna(current_time):
            print(f"Warning: NaN value encountered in Time field at index {idx}. Skipping this point.")
            path_ids.append(current_group)
            continue
        if previous_time is not None:
            gap = current_time - previous_time
            if gap > gap_threshold:
                current_group += 1
        path_ids.append(current_group)
        previous_time = current_time
    
    gdf_sorted[group_field] = path_ids
    
    # Step 10: Prompt for Output Shapefile Path
    output_shapefile = input("\nEnter the path for the output paths shapefile (.shp): ").strip('"').strip("'")
    output_dir = os.path.dirname(output_shapefile)
    if output_dir and not os.path.exists(output_dir):
        os.makedirs(output_dir)
    
    # Ensure .shp extension
    if not output_shapefile.lower().endswith('.shp'):
        output_shapefile += '.shp'
    
    # Step 11: Generate Paths
    try:
        # Filter groups with at least two points
        valid_groups = gdf_sorted.groupby(group_field).filter(lambda x: len(x) > 1)
        
        # Check if any valid groups exist
        if valid_groups.empty:
            print("Error: No groups contain more than one point. Cannot create LineStrings.")
            sys.exit(1)
        
        # Group by PathID and create LineStrings
        paths = valid_groups.groupby(group_field)['geometry'].apply(lambda x: LineString(x.tolist())).reset_index()
        
        # Create GeoDataFrame for paths
        paths_gdf = gpd.GeoDataFrame(paths, geometry='geometry')
        
        # Set CRS to match input
        paths_gdf.set_crs(gdf_sorted.crs, inplace=True)
        
        # Save to file
        paths_gdf.to_file(output_shapefile)
        print(f"\nSuccess: Paths have been saved to '{output_shapefile}'.")
    except Exception as e:
        print(f"Error generating paths: {e}")
        sys.exit(1)

if __name__ == "__main__":
    main()

```