{"id":18810411,"url":"https://github.com/absaoss/fixed-width","last_synced_at":"2026-03-09T21:04:51.398Z","repository":{"id":41816999,"uuid":"282804679","full_name":"AbsaOSS/fixed-width","owner":"AbsaOSS","description":null,"archived":false,"fork":false,"pushed_at":"2023-05-05T17:11:03.000Z","size":73,"stargazers_count":5,"open_issues_count":7,"forks_count":0,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-04-12T07:05:51.214Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AbsaOSS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-27T05:42:53.000Z","updated_at":"2023-11-15T19:43:10.000Z","dependencies_parsed_at":"2022-08-11T18:20:50.444Z","dependency_job_id":null,"html_url":"https://github.com/AbsaOSS/fixed-width","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Ffixed-width","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Ffixed-width/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Ffixed-width/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Ffixed-width/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AbsaOSS","download_url":"https://codeload.github.com/AbsaOSS/fixed-width/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223603288,"owners_count":17172077,"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":[],"created_at":"2024-11-07T23:20:07.117Z","updated_at":"2026-03-09T21:04:51.370Z","avatar_url":"https://github.com/AbsaOSS.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fixed-Width Data Source for Apache Spark\n\nA library for parsing FixedWidth data with Apache Spark. FixedWidth file is a flat file where each column has a fixed width (number of characters) and this is specified in a \nschema.\n\n## Usage\n\nYou can link against this library in your program at the following coordinates:\n\n#### Scala 2.11\n\n```\ngroupId: za.co.absa\nartifactId: fixed-width_2.11\nversion: 0.2.0\n```\n\n#### Scala 2.12\n\n```\ngroupId: za.co.absa\nartifactId: fixed-width_2.12\nversion: 0.2.0\n```\n \n\n### Using with Spark shell\nThis package can be added to Spark using the `--packages` command line option. For example, to include it when starting the spark shell:\n\n\n#### Spark compiled with Scala 2.11\n\n```shell\n$SPARK_HOME/bin/spark-shell --packages za.co.absa:fixed-width_2.11:0.2.0\n```\n\n#### Spark compiled with Scala 2.12\n\n```shell\n$SPARK_HOME/bin/spark-shell --packages za.co.absa:fixed-width_2.12:0.2.0\n```\n\n### Usage in code\n\n```scala\nimport org.apache.spark.sql.types._\nimport org.apache.spark.sql.SparkSession\n\nval sparkBuilder = SparkSession.builder().appName(\"Example\")\nval spark = sparkBuilder.getOrCreate()\n\nval metadata = new MetadataBuilder().putLong(\"width\", 10).build()\nval schema = StructType(\n  List(\n    StructField(\"someColumn\", StringType, true, metadata),\n    StructField(\"secondColumn\", StringType, true, metadata)\n  )\n)\n\nval dataframe = spark\n  .read\n  .format(\"fixed-width\")\n  .option(\"trimValues\", \"true\")\n  .schema(schema)\n  .load(\"/path/to/data/fixedWidthData\")\n```\n\n### Options\n| Option | Value | Explanation |\n|---|---|---|\n| trimValues | true/false | Should the whitespaces around data be trimmed |\n| charset | charset name (e.g. UTF-8) | Any valid charset used to write the FixedWidth file |\n\n### How to generate Code coverage report\n```sbt\nsbt jacoco\n```\nCode coverage will be generated on path:\n```\n{project-root}/target/scala-{scala_version}/jacoco/report/html\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsaoss%2Ffixed-width","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabsaoss%2Ffixed-width","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsaoss%2Ffixed-width/lists"}