-1

I want to change my code from read and process from a string of sentence into read from a csv file, and process line by line.

This is my program in VS Code.

import paralleldots
paralleldots.set_api_key("API KEY")


# for single sentence
text="Come on, lets play together"
lang_code="en"
response=paralleldots.sentiment(text,lang_code)
print(response)

I expect the output is run for each line of sentence in a specific csv file, instead of just from a string of sentence.

swm
  • 71
  • 1
  • 10
  • 1
    Hello, welcome to Stack Overflow ! If you already haven't, please read [how to ask](https://stackoverflow.com/help/how-to-ask). What have you tried ? –  May 26 '19 at 15:37

1 Answers1

0
fp = open('C:/Users/User/Desktop/hj.txt',encoding='utf-8' ,errors='ignore' ) # Open file on read mode
lines = fp.read().split("\n") # Create a list containing all lines
fp.close() # Close file
print(lines)
#print("----------------------------------------------...------\n") 

print("\nThe emotion analysis results for each sentence in the file .txt :") 
print("------------------------------------------------...------\n") 
response=paralleldots.batch_emotion(lines)
print(response)

This worked well.

swm
  • 71
  • 1
  • 10