This repository was archived by the owner on Jan 28, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
Reading from a File
Vladimir Jimenez edited this page Jun 5, 2015
·
1 revision
PhpSoda always submits all of its data to Socrata as JSON but upsert() and replace() can "deal" with more formats.
Uploading data from a JSON file is as simple as calling PHP's file_get_contents() and storing it in a variable.
$json = file_get_contents("path/to/dataset.json");
$ds->upsert($json);PhpSoda doesn't handle CSV internally but it does provide a CSV to JSON conversion by using the CsvConverter class.
If you have CSV stored in a string, pass it to a new CsvConverter instance and then pass that instance to the dataset object.
$csv = new CsvConverter($csvString);
$ds->upsert($csv);To read from a file, you may use the static function fromFile() and then pass it to the dataset object.
$csv = CsvConverter::fromFile("path/to/dataset.csv");
$ds->upsert($csv);Found an issue? Something not clear? Submit an issue to let us know!