nswamy commented on a change in pull request #14503: API to create RecordIO 
files
URL: https://github.com/apache/incubator-mxnet/pull/14503#discussion_r269758130
 
 

 ##########
 File path: python/mxnet/io/io.py
 ##########
 @@ -966,6 +985,165 @@ def creator(*args, **kwargs):
     creator.__doc__ = doc_str
     return creator
 
+
+def _read_list(list_file, batch_size):
+    """
+    Helper function that reads the .lst file, binds it in
+    a generator and returns a batched version of the generator.
+    Parameters
+    ----------
+    list_file: input list file.
+    batch_size: batch size of the generator
+    Returns
+    -------
+    item iterator that contains information in .lst file
+    """
+    def get_generator():
+        with open(list_file) as fin:
+            while True:
+                line = fin.readline()
+                if not line:
+                    break
+                line = [i.strip() for i in line.strip().split('\t')]
+                line_len = len(line)
+                # check the data format of .lst file
+                if line_len < 3:
+                    logging.info("lst should have at least has three parts, "
+                                + "but only has {} parts for 
{}".format(line_len, line))
+                    continue
+                try:
+                    item = [int(line[0])] + [line[-1]] + [float(i) for i in 
line[1:-1]]
+                except Exception as e:
+                    logging.info('Parsing lst met error for {}, detail: 
{}'.format(line, e))
+                    continue
+                yield item
+    data_iter = iter(get_generator())
+    data_batch = list(itertools.islice(data_iter, batch_size))
+    while data_batch:
+        yield data_batch
+        data_batch = list(itertools.islice(data_iter, batch_size))
+
+def _read_worker(q_out, transforms, color, quality, encoding, data_record):
 
 Review comment:
   `transforms` -> `transformer`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to