Python Mac OS Help Remote
Budget: $15 – $25 USD
I am trying to use Visual Studio Code, to work with a Python script utilising my Openai API key. I am getting an error.
This is my code:
import openai
import pandas as pd
df = pd.read_csv("input.csv")
# Set OpenAI API key
openai.api_key = "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"
results = []
for index, row in df.iterrows():
prompt = f"Please write a detailed article about {row['topic']}. Use this information to write the article: {row['context']}"
response = openai.Completion.create(engine="text-davinci-003", prompt=prompt, temperature=0.7,max_tokens=2048,top_p=0.5)
results.append([row['topic'], response.choices[0].text])
output_df = pd.DataFrame(results, columns = ['Topic', 'Generated Text'])
output_df.to_csv('output.csv', index=False)
This is the error:
(base) greggillespie@192-168-1-102 Desktop % /Users/greggillespie/opt/anaconda3/bin/python /Users/greggillespie/Desktop/openai-creator.py
Traceback (most recent call last):
File "/Users/greggillespie/Desktop/openai-creator.py", line 4, in <module>
df = pd.read_csv("input.csv")
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 678, in read_csv
return _read(filepath_or_buffer, kwds)
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 581, in _read
return parser.read(nrows)
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1253, in read
index, columns, col_dict = self._engine.read(nrows)
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/io/parsers/c_parser_wrapper.py", line 225, in read
chunks = self._reader.read_low_memory(nrows)
File "pandas/_libs/parsers.pyx", line 805, in pandas._libs.parsers.TextReader.read_low_memory
File "pandas/_libs/parsers.pyx", line 861, in pandas._libs.parsers.TextReader._read_rows
File "pandas/_libs/parsers.pyx", line 847, in pandas._libs.parsers.TextReader._tokenize_rows
File "pandas/_libs/parsers.pyx", line 1960, in pandas._libs.parsers.raise_parser_error
pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 2
End.
I need someone to help me remotely workout the problem and find the solution. Just need some general guidance on working with the Mac OS Terminal, as I am just a beginner with this.
Requirements:
Python scripting
Mac OS
Remote connection and problem solving
Mac OS Terminal help
This job is extremely urgent, so I need someone who can help today, so you must be able to start right away.
Thanks
Greg
This is my code:
import openai
import pandas as pd
df = pd.read_csv("input.csv")
# Set OpenAI API key
openai.api_key = "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"
results = []
for index, row in df.iterrows():
prompt = f"Please write a detailed article about {row['topic']}. Use this information to write the article: {row['context']}"
response = openai.Completion.create(engine="text-davinci-003", prompt=prompt, temperature=0.7,max_tokens=2048,top_p=0.5)
results.append([row['topic'], response.choices[0].text])
output_df = pd.DataFrame(results, columns = ['Topic', 'Generated Text'])
output_df.to_csv('output.csv', index=False)
This is the error:
(base) greggillespie@192-168-1-102 Desktop % /Users/greggillespie/opt/anaconda3/bin/python /Users/greggillespie/Desktop/openai-creator.py
Traceback (most recent call last):
File "/Users/greggillespie/Desktop/openai-creator.py", line 4, in <module>
df = pd.read_csv("input.csv")
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 678, in read_csv
return _read(filepath_or_buffer, kwds)
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 581, in _read
return parser.read(nrows)
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1253, in read
index, columns, col_dict = self._engine.read(nrows)
File "/Users/greggillespie/opt/anaconda3/lib/python3.9/site-packages/pandas/io/parsers/c_parser_wrapper.py", line 225, in read
chunks = self._reader.read_low_memory(nrows)
File "pandas/_libs/parsers.pyx", line 805, in pandas._libs.parsers.TextReader.read_low_memory
File "pandas/_libs/parsers.pyx", line 861, in pandas._libs.parsers.TextReader._read_rows
File "pandas/_libs/parsers.pyx", line 847, in pandas._libs.parsers.TextReader._tokenize_rows
File "pandas/_libs/parsers.pyx", line 1960, in pandas._libs.parsers.raise_parser_error
pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 2
End.
I need someone to help me remotely workout the problem and find the solution. Just need some general guidance on working with the Mac OS Terminal, as I am just a beginner with this.
Requirements:
Python scripting
Mac OS
Remote connection and problem solving
Mac OS Terminal help
This job is extremely urgent, so I need someone who can help today, so you must be able to start right away.
Thanks
Greg