
from __future__ import print_function
from __future__ import unicode_literals
import pytablereader

print("\n".join([
    "load from URL",
    "==============",
]))

loader = pytablereader.TableUrlLoader(
    "https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks",
    "html")

with open("hoge.rst", "w", encoding="utf-8") as f:
    for table_data in loader.load():
        print("{:s}".format(table_data.dumps()))
        f.write(table_data.dumps())


from __future__ import print_function
from __future__ import unicode_literals
import io

import pytablereader

print("\n".join([
    "load from URL",
    "==============",
]))

loader = pytablereader.TableUrlLoader(
    "https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks",
    "html")

with io.open("hoge.rst", "w", encoding=loader.encoding) as f:
    for table_data in loader.load():
        print("{:s}".format(table_data.dumps()))
        f.write(table_data.dumps())

Fix for python 2 compatibility
Fix for python 2 compatibility

  
  from __future__ import print_function
  from __future__ import unicode_literals
+ import io
+ 
  import pytablereader
  
  print("\n".join([
      "load from URL",
      "==============",
  ]))
  
  loader = pytablereader.TableUrlLoader(
      "https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks",
      "html")
  
- with open("hoge.rst", "w", encoding="utf-8") as f:
+ with io.open("hoge.rst", "w", encoding=loader.encoding) as f:
      for table_data in loader.load():
          print("{:s}".format(table_data.dumps()))
          f.write(table_data.dumps())
  
Fix for python 2 compatibility
## Code Before:

from __future__ import print_function
from __future__ import unicode_literals
import pytablereader

print("\n".join([
    "load from URL",
    "==============",
]))

loader = pytablereader.TableUrlLoader(
    "https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks",
    "html")

with open("hoge.rst", "w", encoding="utf-8") as f:
    for table_data in loader.load():
        print("{:s}".format(table_data.dumps()))
        f.write(table_data.dumps())

## Instruction:
Fix for python 2 compatibility
## Code After:

from __future__ import print_function
from __future__ import unicode_literals
import io

import pytablereader

print("\n".join([
    "load from URL",
    "==============",
]))

loader = pytablereader.TableUrlLoader(
    "https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks",
    "html")

with io.open("hoge.rst", "w", encoding=loader.encoding) as f:
    for table_data in loader.load():
        print("{:s}".format(table_data.dumps()))
        f.write(table_data.dumps())
