Skip to content

Instantly share code, notes, and snippets.

@leandro
Last active October 17, 2022 21:46
Show Gist options
  • Save leandro/dd21cf4c178bfe81896b65c8002ffe74 to your computer and use it in GitHub Desktop.
Save leandro/dd21cf4c178bfe81896b65c8002ffe74 to your computer and use it in GitHub Desktop.
How to iterate a file content by chunks
app/models/branch_action_node.rb:class BranchActionNode < ActionNode
app/models/built_custom_document.rb:class BuiltCustomDocument < CustomDocument
app/models/call_rail_call.rb:class CallRailCall < Call
app/models/custom_booking.rb:class CustomBooking < CustomForm
app/models/custom_booking_action_node.rb:class CustomBookingActionNode < CustomFormActionNode
app/models/custom_document_separator_block.rb:class CustomDocumentSeparatorBlock < CustomDocumentBlock
app/models/custom_field/client.rb:class CustomField::Client < CustomField
app/models/email.rb:class Email < ContactInformation
app/models/event_automation.rb:class EventAutomation < Automation
app/models/event_automation_target.rb:class EventAutomationTarget < AutomationList
app/models/firm_permission.rb:class FirmPermission < Permission
app/models/referrer.rb:class Referrer < Campaign
app/models/timeline_activity/appointment_request.rb:class TimelineActivity::AppointmentRequest < TimelineActivity
./app/models/action_node.rb
./app/models/automation.rb
./app/models/automation_list.rb
./app/models/call.rb
./app/models/campaign.rb
./app/models/contact_information.rb
./app/models/custom_document.rb
./app/models/custom_document_block.rb
./app/models/custom_form.rb
./app/models/custom_field.rb
./app/models/permission.rb
./app/models/timeline_activity.rb
file_path = './file-example.txt'
chunk_size = 256
File.open(file_path, 'rb') do |file|
while data = file.read(chunk_size)
puts data, '-' * 50
end
end
app/models/branch_action_node.rb:class BranchActionNode < ActionNode
app/models/built_custom_document.rb:class BuiltCustomDocument < CustomDocument
app/models/call_rail_call.rb:class CallRailCall < Call
app/models/custom_booking.rb:class CustomBooking < Cu
--------------------------------------------------
stomForm
app/models/custom_booking_action_node.rb:class CustomBookingActionNode < CustomFormActionNode
app/models/custom_document_separator_block.rb:class CustomDocumentSeparatorBlock < CustomDocumentBlock
app/models/custom_field/client.rb:class CustomFiel
--------------------------------------------------
d::Client < CustomField
app/models/email.rb:class Email < ContactInformation
app/models/event_automation.rb:class EventAutomation < Automation
app/models/event_automation_target.rb:class EventAutomationTarget < AutomationList
app/models/firm_permission.rb:
--------------------------------------------------
class FirmPermission < Permission
app/models/referrer.rb:class Referrer < Campaign
app/models/timeline_activity/appointment_request.rb:class TimelineActivity::AppointmentRequest < TimelineActivity
./app/models/action_node.rb
./app/models/automation.rb
./a
--------------------------------------------------
pp/models/automation_list.rb
./app/models/call.rb
./app/models/campaign.rb
./app/models/contact_information.rb
./app/models/custom_document.rb
./app/models/custom_document_block.rb
./app/models/custom_form.rb
./app/models/custom_field.rb
./app/models/permi
--------------------------------------------------
ssion.rb
./app/models/timeline_activity.rb
--------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment