https://github.com/cronokirby/serve-csv

Create a web API from static csv files

https://github.com/cronokirby/serve-csv

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.5%) to scientific vocabulary

Keywords

api csv golang json-api web
Last synced: 5 months ago · JSON representation

Repository

Create a web API from static csv files

Basic Info
  • Host: GitHub
  • Owner: cronokirby
  • License: mit
  • Language: Go
  • Default Branch: master
  • Size: 17.6 KB
Statistics
  • Stars: 5
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
api csv golang json-api web
Created over 6 years ago · Last pushed over 6 years ago
Metadata Files
Readme License

README.md

serve-csv

serve-csv is a small CLI program that allows you to start serving a folder of CSV files as a JSON API. Each CSV file is required to come with a JSON file specifying how each column maps to a JSON field.

Example

The example data for this section can be found in the example-data folder.

To be able to serve CSV, we need to have some data we want to serve. Let's put the following rows into example-data/people.csv: "John","Smith" "Alexa","Miller" "Anthony","Hopkins" "Maxi","Toshins" "Clarice","Cromwell"

Before we can serve this file, we need to have a corresponding example-data/people.json file, which tells us how to convert each column into a JSON field. This file looks like this: json {"fields": ["firstName", "lastName"], "types": ["string", "string"]}

The fields field contains a list of names, one for each column, telling the program what name to use as a field for that column. The types field is an array of the same length as fields, one element per column again, where each element specifies what type the field in that row should be interpreted as. The available types atm are "string" and "int". "string" will leave the column as a JSON string, and "int" as a number.

Given this JSON schema, the first row of our CSV will go from: "John","Smith" to json {"firstName": "John", "lastName": "Smith"}

To serve this folder as an API, we can do: serve-csv example-data

Before starting the API, this will first make sure that each CSV file in the folder has a corresponding JSON schema. The JSON schemas will also be checked for consistency with the format we aligned above. Finally, the CSV file will be scanned to check for consistency with the schema as well.

The JSON data for our example should be accessible after the previous command at: http://localhost:1234/people.

For each CSV file, the program creates an endpoint to fetch all of the rows, as well as a parameterised endpoint for a single row. For example, our people.csv file maps to a /people endpoint, as well as a /people/i endpoint for the ith row (starting at 0). If we had a cats.csv file, this would get its own /cats and /cats/i endpoints as well, etc.

Usage

``` usage: serve-csv []

Flags: --help Show context-sensitive help (also try --help-long and --help-man). -p, --port="1234" The port to listen on

Args:

The directory to serve ```

Owner

  • Name: Lúcás Meier
  • Login: cronokirby
  • Kind: user
  • Location: Seattle

"apprentice cryptographer"

GitHub Events

Total
Last Year

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 15
  • Total Committers: 1
  • Avg Commits per committer: 15.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Lúcás Meier c****y@g****m 15

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 0
proxy.golang.org: github.com/cronokirby/serve-csv
  • Versions: 0
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 7.0%
Average: 7.2%
Dependent repos count: 7.5%
Last synced: 6 months ago