@@ -121,7 +121,7 @@ def read_geopandas(
121121 ).replace ("==" , "=" )
122122 glob_func = _get_glob_func (file_system )
123123 suffix : str = Path (gcs_path ).suffix
124- paths = glob_func (str ( Path ( gcs_path ) / expression / f" *{ suffix } ") )
124+ paths = glob_func (_standardize_path ( gcs_path ) + f"/ { expression } / *{ suffix } " )
125125 if paths :
126126 return _read_geopandas_from_iterable (
127127 paths ,
@@ -256,7 +256,7 @@ def _read_pyarrow(path: str, file_system, mask=None, **kwargs) -> pyarrow.Table
256256 if not len (
257257 {
258258 x
259- for x in glob_func (str (Path (path ) / " **" ))
259+ for x in glob_func (str (_standardize_path (path ) + "/ **" ))
260260 if not paths_are_equal (path , x )
261261 }
262262 ):
@@ -618,15 +618,17 @@ def as_partition_part(col: str, value: Any) -> str:
618618 as_partition_part (col , value )
619619 for col , value in zip (partition_cols , group , strict = True )
620620 )
621- paths .append (Path (path ) / partition_parts )
621+ paths .append (_standardize_path (path ) + f"/ { partition_parts } " )
622622 dfs .append (rows )
623623
624624 def threaded_write (rows : DataFrame , path : str ) -> None :
625625 if basename_template is None :
626626 this_basename = (uuid .uuid4 ().hex + "-{i}.parquet" ).replace ("-{i}" , "0" )
627627 else :
628628 this_basename = basename_template .replace ("-{i}" , "0" )
629- for i , sibling_path in enumerate (sorted (glob_func (str (Path (path ) / "**" )))):
629+ for i , sibling_path in enumerate (
630+ sorted (glob_func (str (_standardize_path (path ) + "/**" )))
631+ ):
630632 if paths_are_equal (sibling_path , path ):
631633 continue
632634 if existing_data_behavior == "delete_matching" :
@@ -638,7 +640,7 @@ def threaded_write(rows: DataFrame, path: str) -> None:
638640 else :
639641 this_basename = basename_template .replace ("-{i}" , str (i + 1 ))
640642
641- out_path = str (Path (path ) / this_basename )
643+ out_path = str (_standardize_path (path ) + "/" + this_basename )
642644 try :
643645 with file_system .open (out_path , mode = "wb" ) as file :
644646 write_func (rows , file , schema = schema , ** kwargs )
@@ -780,7 +782,7 @@ def _read_partitioned_parquet(
780782 glob_func = _get_glob_func (file_system )
781783
782784 if child_paths is None :
783- child_paths = list (glob_func (str (Path (path ) / " **/*.parquet" )))
785+ child_paths = list (glob_func (str (_standardize_path (path ) + "/ **/*.parquet" )))
784786
785787 filters = _filters_to_expression (filters )
786788
@@ -830,7 +832,7 @@ def get_child_paths(path, file_system) -> list[str]:
830832 glob_func = _get_glob_func (file_system )
831833 return [
832834 x
833- for x in glob_func (str (Path (path ) / " **/*.parquet" ))
835+ for x in glob_func (str (_standardize_path (path ) + "/ **/*.parquet" ))
834836 if not paths_are_equal (x , path )
835837 ]
836838
@@ -938,3 +940,8 @@ def _maybe_strip_prefix(path, file_system):
938940 if isinstance (file_system , GCSFileSystem ) and path .startswith ("gs://" ):
939941 return path .replace ("gs://" , "" )
940942 return path
943+
944+
945+ def _standardize_path (path : str | Path ) -> str :
946+ """Make sure delimiter is '/' and path ends without '/'."""
947+ return str (path ).replace ("\\ " , "/" ).replace (r"\"" , "/" )
0 commit comments