Pandas是数据分析三大剑客之一,是Python的核心数据分析库

import psycopg2
from sqlalchemy import create_engine
import pandas as pd
from pandas import DataFrame
 
from io import StringIO
 
if __name__ == '__main__':
    # 读取文本数据:
    # sep标识分隔符,分隔符为\t,即制表符,表示列与列之间用\t分开。
    # header=None 表示txt文件的第一行不是列的名字,是数据。若不写head=None,则读入txt数据时,会没了第一行
    # nrows=5
    # encoding='utf-8'  # 指定文件的字符编码
    table = pd.read_table('D:\\Data\\fall11_urls.txt', sep='\t', header=None, encoding='utf-8')
 
    # 给每列加上列名
    table.columns = ['x', 'y']
 
    # 添加上一列数据,默认值是1
    # table['z'] = 1
    print(table)
 
    # with open('D:\\Data\\fall11_urls.txt', 'r', encoding='utf-8') as f:
    #     for line in f:
    #         if line.count('\n') == len(line):
    #             continue
    #         for
    # data1 = pd.DataFrame(data)
    # DataFrame 类型转换为IO缓冲区中的str类型
    # output = StringIO()
    # data1.to_csv(output, sep='\t', index=False, header=False)
    # output1 = output.getvalue()
 
    # str = '''http://www.hollanderclub.nl/Foto's%20KleindierenEXpo%202009/HPIM4337-blauw.JPG'''
    #
    # print(str)
 
    # https://blog.csdn.net/Spratumn/article/details/100631510 集中常见的数据构建方式
    # https: // blog.csdn.net / ZHANGJING199402 / article / details / 80269632
    # https://blog.csdn.net/skye1208/article/details/90264431   pg自身的快速数据导入方式。