• unicodecsv reader & writer


    def export_supervision_authorities(self, *args, **options):
            writer = unicodecsv.DictWriter(open(options['filename'], 'wb'), (
                'name', 'email', 'address', 'contact', 'jurisdiction__slug', 'other_names', 'description', 'tags', 'parent__name', 'classification', 'url', 'website_dump', 'request_note'
            ))
            writer.writeheader()
            for authority in SupervisionAuthority.objects.all():
                slug = slugify(authority.name)
                authority.fds_url = 'https://fragdenstaat.de/behoerde/%s/' % slug
                authority.save()
                writer.writerow({
                    'name': authority.name,
                    'email': authority.email,
                    'address': authority.address,
                    'contact': authority.contact,
                    'jurisdiction__slug': slugify(authority.state.name),
                    'classification': 'Heimaufsicht'
                }) 
    
    writer = unicodecsv.writer(open(csv_write_name, 'wb'))
    writer.writerow(['field1', 'field2', 'field3'])
    

      

    import re
    import unicodecsv

    f = open('../content_6_18.csv', 'rb')
    f2 = open('pattern_1.csv', 'wb')
    reader = unicodecsv.reader(f)

    # utf-8-sig 防止个别字符乱码

    writer = unicodecsv.writer(f, encoding='utf-8-sig')

    writer.writerow([
    'listingHash',
    'titleDisplay',
    'before',
    'after',
    'source',
    ])

    for index, line in enumerate(reader):
    if index == 0:
    continue

    listingHash, desc, titleDisplay, source = line


    writer.writerow([
    listingHash,
    titleDisplay,
    desc,
    desc_after,
    source,
    ])

    f.close()
    f2.close()

    field1
  • 相关阅读:
    TCP三次握手和四次挥手详解
    Core Bluetooth Programming Guide
    iBeacon
    Xcode6:The file couldn’t be opened because you don’t have permission to view it
    关于IOS的蓝牙(转)
    iPad accessory communication through UART
    关于蓝牙设备与ios连接后,自动打开一个app
    Protocol
    闪屏效果
    修改avd路径
  • 原文地址:https://www.cnblogs.com/NachoLau/p/11127866.html
Copyright © 2020-2023  润新知