Questions tagged [chunks]

A chunk is a fragment of information which is used in many multimedia formats

A chunk is a fragment of information which is used in many multimedia formats, such as PNG, IFF, MP3 and AVI.

Each chunk contains a header which indicates some parameters (e.g. the type of chunk, comments, size etc.) In the middle there is a variable area containing data which are decoded by the program from the parameters in the header. Chunks may also be fragments of information which are downloaded or managed by P2P programs. In distributed computing, a chunk is a set of data which are sent to a processor or one of the parts of a computer for processing. For example a sub-set of rows of a matrix.

901 questions
3069
votes
69 answers

How do I split a list into equally-sized chunks?

How do I split a list of arbitrary length into equal sized chunks? See also: How to iterate over a list in chunks. To chunk strings, see Split string every nth character?.
jespern
  • 32,466
  • 3
  • 23
  • 12
682
votes
40 answers

How to iterate over a list in chunks

I have a Python script which takes as input a list of integers, which I need to work with four integers at a time. Unfortunately, I don't have control of the input, or I'd have it passed in as a list of four-element tuples. Currently, I'm…
Ben Blank
  • 54,908
  • 28
  • 127
  • 156
311
votes
16 answers

How do I read a large csv file with pandas?

I am trying to read a large csv file (aprox. 6 GB) in pandas and i am getting a memory error: MemoryError Traceback (most recent call last) in () ----> 1…
Rajkumar Kumawat
  • 3,627
  • 3
  • 12
  • 8
235
votes
36 answers

Splitting a list into N parts of approximately equal length

What is the best way to divide a list into roughly equal parts? For example, if the list has 7 elements and is split it into 2 parts, we want to get 3 elements in one part, and the other should have 4 elements. I'm looking for something like…
user248237
64
votes
4 answers

'git stash apply' with Interactive Mode

I have a serie of files into a stash (stash{0}) and I would like to git apply just some parts/hunks of these files (usually known as Interactive mode). Is it possible? I've seen that is possible to perform a git stash save -p 'Stash name' but it…
Kamafeather
  • 8,663
  • 14
  • 69
  • 99
59
votes
21 answers

How do I split or chunk a list into equal parts, with Dart?

Assume I have a list like: var letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']; I would like a list of lists of 2 elements each: var chunks = [['a', 'b'], ['c', 'd'], ['e', 'f'], ['g', 'h']]; What's a good way to do this with Dart?
Seth Ladd
  • 112,095
  • 66
  • 196
  • 279
33
votes
3 answers

Pandas SQL chunksize

This is more of a question on understanding than programming. I am quite new to Pandas and SQL. I am using pandas to read data from SQL with some specific chunksize. When I run a sql query e.g. import pandas as pd df = pd.read_sql_query('select…
Nitin Kumar
  • 361
  • 1
  • 4
  • 4
26
votes
1 answer

Paging python lists in slices of 4 items

Possible Duplicate: How do you split a list into evenly sized chunks in Python? mylist = [1, 2, 3, 4, 5, 6, 7, 8, 9] I need to pass blocks of these to a third party API that can only deal with 4 items at a time. I could do one at a time but it's…
Oli
  • 235,628
  • 64
  • 220
  • 299
25
votes
3 answers

How do you split reading a large csv file into evenly-sized chunks in Python?

In a basic I had the next process. import csv reader = csv.reader(open('huge_file.csv', 'rb')) for line in reader: process_line(line) See this related question. I want to send the process line every 100 rows, to implement batch sharding. The…
Mario César
  • 3,699
  • 2
  • 27
  • 42
19
votes
3 answers

Why to use iter_content and chunk_size in python requests

Why should I use iter_content and specially I'm really confused with the purpose using of chunk_size , as I have tried using it and in every way the file seems to be saved after downloading successfully. g = requests.get(url, stream=True) with…
Andriken sonwane
  • 383
  • 1
  • 5
  • 14
17
votes
4 answers

How to split string into chunks in Rust to insert spaces

I'm attempting to learn Rust. And a recent problem I've encountered is the following: given a String, that is exactly some multiple of n, I want to split the string into chunks of size n, and insert a space in between these chunks, then collect back…
Zeke
  • 333
  • 1
  • 3
  • 7
17
votes
6 answers

Can I turn off create-react-app chunking mechanism?

I am setting up my React app project using create-react-app. I was wondering if there is a way to turn-off the chunking mechanism that is built-in into the react scripts. The thing is that I need to fix the name of the bundle created on the build.
Darko
  • 525
  • 1
  • 4
  • 14
15
votes
2 answers

PeerJS/WebRTC connection fails on rapid chunks transmittion

I'm using PeerJS, but thought that this problem can be about WebRTC in general, hope You can help me out: I'm trying to write a simple peer-to-peer file sharing. I'm using serialisation: "none" for PeerJS connection DataChannel, as I'm sending just…
Max Yari
  • 3,617
  • 5
  • 32
  • 56
14
votes
2 answers

How to change knitr options mid chunk

Hi I would like to change chunk options, mid chunk, without having to create a new chunk.. running the following code I would expect to get two very different size outputs, but for some reason this does not seem to be the case. Also the second plot…
h.l.m
  • 13,015
  • 22
  • 82
  • 169
13
votes
3 answers

How to load Pickle file in chunks?

Is there any option to load a pickle file in chunks? I know we can save the data in CSV and load it in chunks. But other than CSV, is there any option to load a pickle file or any python native file in chunks?
Naren Babu R
  • 453
  • 2
  • 9
  • 33
1
2 3
60 61