{"id":25981300,"url":"https://github.com/clojure-finance/clojask-io","last_synced_at":"2025-03-05T08:25:17.553Z","repository":{"id":43922133,"uuid":"504850307","full_name":"clojure-finance/clojask-io","owner":"clojure-finance","description":"Reading and writing various file formats for Clojask: clojask-io is a library designed to extend the file support for Clojask. This library can also be used alone to read in and output dataset files. ","archived":false,"fork":false,"pushed_at":"2023-07-06T01:50:32.000Z","size":56,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T04:32:26.717Z","etag":null,"topics":["clojure","data-science","dataframe","file-format","input-output"],"latest_commit_sha":null,"homepage":"https://clojure-finance.github.io/clojask-website","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clojure-finance.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-18T13:24:08.000Z","updated_at":"2023-07-29T04:57:18.000Z","dependencies_parsed_at":"2023-01-23T14:30:37.290Z","dependency_job_id":null,"html_url":"https://github.com/clojure-finance/clojask-io","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure-finance%2Fclojask-io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure-finance%2Fclojask-io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure-finance%2Fclojask-io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure-finance%2Fclojask-io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clojure-finance","download_url":"https://codeload.github.com/clojure-finance/clojask-io/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241794100,"owners_count":20021194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","data-science","dataframe","file-format","input-output"],"created_at":"2025-03-05T08:25:16.816Z","updated_at":"2025-03-05T08:25:17.547Z","avatar_url":"https://github.com/clojure-finance.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clojask-io\n\nA Clojure library designed to extend the file support for [Clojask](https://github.com/clojure-finance/clojask). This library can also be used alone to read in and output dataset files.\n\n## Installation\n\nAvailable on Clojars: [![Clojars Project](https://img.shields.io/clojars/v/com.github.clojure-finance/clojask-io.svg)](https://clojars.org/com.github.clojure-finance/clojask-io)\n\n## APIs\n\n### NS: clojask-io.core\n\n#### `supports`\n\nCheck if this library supports to read and write this format of file.\n\n| Argument | Type   | Function                                                     | Remarks |\n| -------- | ------ | ------------------------------------------------------------ | ------- |\n| `format` | String | Indicates the format of type, e.g. \"csv\", \"xls\", \"txt\", etc. |         |\n\n**Return**\n\nBoolean\n\n\u003cbr\u003e\n\n#### `infer-format`\n\nInfer the file format from the path (get the substring after the last `.`).\n\n| Argument | Type   | Function                                                     | Remarks                                                      |\n| -------- | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ |\n| `path`   | String | Indicates where to find the file (either on local machine or online) | - For local files, absolute / relative path of the file\u003cbr /\u003e- For online resources, url of the resources |\n\n**Return**\n\nString, such as \"csv\", \"xls\" (`nil` if fails to infer)\n\n-----\n\n### NS: clojask-io.input\n\n#### `read-file`\n\nRead in a file as lazy sequence. Optionally, provide size of the file, corresponding output functions.\n\n*Supported file types: **csv, txt, dat, tsv, tab**. The file size can be larger than memory.* \n\n| Argument   | Type                                     | Function                                                     | Remarks                                                      |\n| ---------- | ---------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |\n| `path`     | String                                   | Indicates where to find the file (either on local machine or online) | - For local files, absolute / relative path of the file\u003cbr/\u003e- For online resources, url of the resources |\n| [`format`] | String                                   | The format of the file                                       | Will be inferred from the path suffix if not provided. Will imply the separator (`sep`) based on pre-setting. |\n| [`sep`]    | String / java.util.regex.Pattern (regex) | The separator of each row of the dataset file                |                                                              |\n| [`wrap`]   | String                                   | Wrapper of each value                                        | Sometimes, the file will wrap each value some punctuations, e.g `\"\"` / `''`. Can remove them automatically by setting this argument. Does not support asymmetric wrappers. |\n| [`stat`]   | Boolean                                  | Whether to get the size of the file                          | If true, the return value will add a :size key-value pair in unit of bytes. Size value will be `nil` if cannot be retrieved. |\n| [`output`] | Boolean                                  | Whether to also return the corresponding output function     | If true, the return value will add a :output key-value pair. |\n\n**Return**\n\n{:data `a lazy sequence of vectors representing each row` [:size `the size in byte`] [:output `output function`]}\n\n\n\n#### `read-excel`\n\nRead in an excel file as lazy sequence. Optionally, provide size of the file.\n\n*A simplified wrapper function of [Docjure](https://github.com/mjul/docjure). The excel file should be smaller than memory size.* \n\n| Argument | Type    | Function                                                     | Remarks                                                      |\n| -------- | ------- | ------------------------------------------------------------ | ------------------------------------------------------------ |\n| `path`   | String  | Indicates where to find the file (either on local machine or online) | - For local files, absolute / relative path of the file\u003cbr /\u003e- For online resources, url of the resources |\n| `sheet`  | String  | Name of the sheet                                            |                                                              |\n| [`stat`] | Boolean | Whether to get the size of the file                          | If true, the return value will add a :size key-value pair in unit of bytes. Size value will be `nil` if cannot be retrieved. |\n\n**Return**\n\n{:data `a lazy sequence of vectors representing each row` [:size `the size in byte`]}\n\n----\n\n### NS: clojask-io.output\n\n#### `write-csv`\n\nSynchronously write a collection of collections to a csv-like file.\n\n| Argument    | Type                     | Function                                     | Remarks                                                      |\n| ----------- | ------------------------ | -------------------------------------------- | ------------------------------------------------------------ |\n| `writer`    | `java.io.BufferedWriter` | The writer initialized to the output file    |                                                              |\n| `sequence`  | Collection               | The output content                           | Should a two-dimensional collection                          |\n| `separator` | String                   | The separator between values in the same row |                                                               |\n\n**Implementation**\n\n```clojure\n(defn write-csv\n  \"output to a csv file using a collection of collections\"\n  [writer seq sep]\n  (doseq [row seq]\n    (.write writer (str (str/join sep row) \"\\n\"))\n    ))\n```\n\n**Return**\n\n`nil`\n\n\u003cbr\u003e\n\n#### `write-excel`\n\nSynchronously write a collection of collections to an excel file.\n\n*A simplified wrapper function of [Docjure](https://github.com/mjul/docjure).*\n\n| Argument   | Type       | Function                          | Remarks                                       |\n| ---------- | ---------- | --------------------------------- | --------------------------------------------- |\n| `path`     | String     | Indicates the path of output file | Absolute / relative path of local file system |\n| `sheet`    | String     | Name of the sheet                 |                                               |\n| `sequence` | Collection | The output content                | Should a two-dimensional collection           |\n\n**Return**\n\n`nil`\n\n-----------------------\n\nCopyright © 2022 Clojask-io\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojure-finance%2Fclojask-io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclojure-finance%2Fclojask-io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojure-finance%2Fclojask-io/lists"}