Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python zapier-IOError:[Errno 30]只读文件系统:';products.cvs';_Python_Zapier - Fatal编程技术网

Python zapier-IOError:[Errno 30]只读文件系统:';products.cvs';

Python zapier-IOError:[Errno 30]只读文件系统:';products.cvs';,python,zapier,Python,Zapier,对于那些了解Zapier的人,我正在使用Python制作一个zap,每个月都会触发下面的代码。该代码从我的使用shopify的网站中提取产品,并在.csv文件中返回值。代码在命令提示符下运行良好,但我在Zapier中得到了上面的错误。有人知道如何修复错误吗?请参考下面的错误来源行: 将open('products.csv','w')作为f: 该文件似乎是只读的,可能是由于Zapier端的安全功能。为什么你需要用Zapier来处理这个问题?看起来您并没有以任何方式将此数据传递给另一个服务。为什么你

对于那些了解Zapier的人,我正在使用Python制作一个zap,每个月都会触发下面的代码。该代码从我的使用shopify的网站中提取产品,并在.csv文件中返回值。代码在命令提示符下运行良好,但我在Zapier中得到了上面的错误。有人知道如何修复错误吗?请参考下面的错误来源行:

将open('products.csv','w')作为f:


该文件似乎是只读的,可能是由于Zapier端的安全功能。为什么你需要用Zapier来处理这个问题?看起来您并没有以任何方式将此数据传递给另一个服务。为什么你不能在本地或服务器上处理这个问题?@lanterry有人告诉我Zapier是个好方法。如果我想在本地或服务器上处理这个问题,你能告诉我正确的方向吗?我不知道该怎么做。如果你只需要CSV,就在安装了Python的PC上运行这段代码。
import csv
import json
import urllib2
import sys

url = 'https://blahblah.com'

def get_page(page):
    data = urllib2.urlopen(url + '?page={}'.format(page)).read()
    products = json.loads(data)['products']
    return products

with open('products.csv', 'w') as f:
    writer = csv.writer(f)
    writer.writerow(['Category', 'Name', 'Price', 'Vendor'])
    page = 1
    products = get_page(page)
    while products:
        for product in products:
            name = product['title']
            category = product['product_type']
            vendor = product['vendor']
            for variant in product['variants']:
                price = variant['price']
                row = [category, name, price, vendor]
                row = [uni.encode('utf8') for uni in row]
                writer.writerow(row)
        page += 1
        products = get_page(page)