@@ -413,8 +413,7 @@ def _clean_object(self, user_obj, target=None):
413413 elts = []
414414 for item in user_obj :
415415 elts .append (self ._clean_object (item ))
416- obj ["list" ] = elts
417- return obj
416+ return elts
418417 elif isinstance (user_obj , Var ):
419418 return self ._expand_value_variable (user_obj )
420419 elif isinstance (user_obj , Doc ):
@@ -1511,10 +1510,14 @@ def woql_as(self, *args):
15111510 def file (self , fpath , opts = None ):
15121511 """Provides details of a file source in a JSON format that includes a URL property
15131512
1513+ Note: CSV files can no longer be read from the filesystem. Only files submitted
1514+ as part of the request can be processed. Use remote() for URLs or submit files
1515+ via the API.
1516+
15141517 Parameters
15151518 ----------
1516- fpath : dict
1517- file data source in a JSON format
1519+ fpath : dict or str
1520+ file data source in a JSON format or file path
15181521 opts : input options
15191522 optional
15201523
@@ -1524,7 +1527,7 @@ def file(self, fpath, opts=None):
15241527 query object that can be chained and/or execute
15251528 Example
15261529 -------
1527- To load a local csv file :
1530+ To reference a file (must be submitted with request) :
15281531 >>> WOQLQuery().file("/app/local_files/my.csv")
15291532 See Also
15301533 --------
@@ -1538,8 +1541,10 @@ def file(self, fpath, opts=None):
15381541 if self ._cursor .get ("@type" ):
15391542 self ._wrap_cursor_with_and ()
15401543 self ._cursor ["@type" ] = "QueryResource"
1541- fpath ["@type" ] = "Source"
1542- self ._cursor ["source" ] = fpath
1544+ if isinstance (fpath , str ):
1545+ self ._cursor ["source" ] = {"@type" : "Source" , "file" : fpath }
1546+ else :
1547+ self ._cursor ["source" ] = fpath
15431548 self ._cursor ["format" ] = "csv"
15441549 if opts :
15451550 self ._cursor ["options" ] = opts
@@ -1601,21 +1606,45 @@ def remote(self, uri, opts=None):
16011606 if self ._cursor .get ("@type" ):
16021607 self ._wrap_cursor_with_and ()
16031608 self ._cursor ["@type" ] = "QueryResource"
1604- uri ["@type" ] = "Source"
1605- self ._cursor ["source" ] = uri
1609+ if isinstance (uri , dict ):
1610+ uri ["@type" ] = "Source"
1611+ self ._cursor ["source" ] = uri
1612+ else :
1613+ self ._cursor ["source" ] = {"@type" : "Source" , "url" : uri }
16061614 self ._cursor ["format" ] = "csv"
16071615 if opts :
16081616 self ._cursor ["options" ] = opts
16091617 return self
16101618
16111619 def post (self , fpath , opts = None ):
1620+ """Specifies a file to be posted as part of the request for processing.
1621+
1622+ Note: CSV files can no longer be read from the filesystem. Only files submitted
1623+ as part of the request can be processed. This method should be used with files
1624+ that are uploaded via the API.
1625+
1626+ Parameters
1627+ ----------
1628+ fpath : str or dict
1629+ file path/identifier or dict with file details
1630+ opts : dict, optional
1631+ additional options for file processing
1632+
1633+ Returns
1634+ -------
1635+ WOQLQuery object
1636+ query object that can be chained and/or execute
1637+ """
16121638 if fpath and fpath == "args" :
16131639 return ["source" , "format" , "options" ]
16141640 if self ._cursor .get ("@type" ):
16151641 self ._wrap_cursor_with_and ()
16161642 self ._cursor ["@type" ] = "QueryResource"
1617- fpath ["@type" ] = "Source"
1618- self ._cursor ["source" ] = fpath
1643+ if isinstance (fpath , dict ):
1644+ fpath ["@type" ] = "Source"
1645+ self ._cursor ["source" ] = fpath
1646+ else :
1647+ self ._cursor ["source" ] = {"@type" : "Source" , "post" : fpath }
16191648 self ._cursor ["format" ] = "csv"
16201649 if opts :
16211650 self ._cursor ["options" ] = opts
0 commit comments