Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonl_reader_writer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonl_reader_writer

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

JSONL Reader Writer

jsonl_reader_writer is a Ruby gem that provides utilities for reading, mapping, filtering, and writing JSON Lines formatted files.

Installation

Add this line to your application's Gemfile:

gem 'jsonl_reader_writer'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install jsonl_reader_writer

Usage

require 'jsonl_reader_writer'

# Create a reader instance
reader = JsonlReaderWriter::Reader.new('/path/to/your/jsonl_file.jsonl')

# Read and print each line
reader.each do |data, line_number|
  puts "Line #{line_number + 1}: #{data}"
end

# Filter the data
filtered_data = reader.filter do |data|
  data['some_key'] == 'some_value'
end

# Map the data
mapped_data = reader.map do |data|
  data['some_key']
end

# Create a writer instance
writer = JsonlReaderWriter::Writer.new('/path/to/your/output_file.jsonl')

# Write data
writer.write({ some_key: 'some_value' })

# Write multiple records
records = [
  { record_1_key: 'record_1_value' },
  { record_2_key: 'record_2_value' },
]
writer.write(records)

# Write data with validation
writer.write({ some_key: 'some_value' }, validate: true)

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/your_username/jsonl_reader_writer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 01 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc