This is an automated email from the ASF dual-hosted git repository.

altay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 329b8e3  Use csv reader instead of split to read csv data.
     new a543a2e  Merge pull request #11616 from KevinGG/demo
329b8e3 is described below

commit 329b8e3620c349fa8a729b410b82d0168c5969b7
Author: kevingg <[email protected]>
AuthorDate: Tue May 5 16:01:37 2020 -0700

    Use csv reader instead of split to read csv data.
---
 .../runners/interactive/examples/UsCovidDataExample.ipynb         | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/sdks/python/apache_beam/runners/interactive/examples/UsCovidDataExample.ipynb 
b/sdks/python/apache_beam/runners/interactive/examples/UsCovidDataExample.ipynb
index 4733b1f..cc95268 100644
--- 
a/sdks/python/apache_beam/runners/interactive/examples/UsCovidDataExample.ipynb
+++ 
b/sdks/python/apache_beam/runners/interactive/examples/UsCovidDataExample.ipynb
@@ -199,10 +199,12 @@
    "metadata": {},
    "outputs": [],
    "source": [
+    "from csv import reader\n",
+    "\n",
     "def read_headers(csv_file):\n",
     "  with open(csv_file, 'r') as f:\n",
     "    header_line = f.readline().strip()\n",
-    "  return header_line.split(',')\n",
+    "  return next(reader([header_line]))\n",
     "\n",
     "current_data_headers = read_headers(csv_file_current)"
    ]
@@ -222,7 +224,7 @@
     "    self._schema = schema\n",
     "    \n",
     "  def process(self, element):\n",
-    "    values = [int(val) if val.isdigit() else val for val in 
element.split(',')]\n",
+    "    values = [int(val) if val.isdigit() else val for val in 
next(reader([element]))]\n",
     "    return [self._schema(*values)]"
    ]
   },
@@ -503,7 +505,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.7.3"
+   "version": "3.7.7"
   }
  },
  "nbformat": 4,

Reply via email to