Python Forum
list from a data file problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list from a data file problem
#4
i have struggle with the problem and get my solusion:
with open("clusters.csv", "r") as data_file:
all_words = []
for line in data_file.readlines():
for word in line.split("'. "):
all_words.append(word.lower())
unique_words = set(all_words)
i = 0
xlen = len(unique_words)
xlist = list(unique_words)
while i <= (xlen):

x = xlist[i].find(";"); # längd
x1 = xlist[i].find(",") # 1 comma plats
x2 = x1 + xlist[i].find(",") # 2 comma plats
x3 = xlist[i].find(")") # ) plats
ww = (xlist[i][0:x]) # clusterdata
rr = int(ww[1:x1]) # röd
gg = int(ww[x1+2:x2+1]) # grön
bb = int(ww[x2+3:x3]) # blue
korr_value = (rr, gg, bb, 255)
pixel_value = (rr, gg, bb, 255)

print korr_value
filename = ( str(rr)+"_"+str(gg)+"_"+str(bb) )
suffix = ".png"
thanks to all that hav toughtabout it.
Reply


Messages In This Thread
list from a data file problem - by Marre - Sep-15-2020, 06:05 PM
RE: list from a data file problem - by Gribouillis - Sep-15-2020, 07:01 PM
RE: list from a data file problem - by Marre - Sep-16-2020, 02:54 PM
RE: list from a data file problem - by Marre - Sep-22-2020, 07:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with to check an Input list data with a data read from an external source sacharyya 3 403 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  Problem with "Number List" problem on HackerRank Pnerd 5 2,089 Apr-12-2022, 12:25 AM
Last Post: Pnerd
  Why changing data in a copied list changes the original list? plumberpy 3 2,225 Aug-14-2021, 02:26 AM
Last Post: plumberpy
  Looking for data/info on a perticular data-proccesing problem. MvGulik 9 3,850 May-01-2021, 07:43 AM
Last Post: MvGulik
  xml file creation from an XML file template and data from an excel file naji_python 1 2,106 Dec-21-2020, 03:24 PM
Last Post: Gribouillis
  Regex text file to store data in list TheSithSiggi 1 1,528 Dec-03-2020, 04:46 PM
Last Post: bowlofred
  How to save CSV file data into the Azure Data Lake Storage Gen2 table? Mangesh121 0 2,109 Jun-26-2020, 11:59 AM
Last Post: Mangesh121
  Problem reading data from file player1681 2 3,741 May-22-2020, 08:57 AM
Last Post: player1681
  problem coverting string data file to dictionary AKNL 22 6,427 Mar-10-2020, 01:27 PM
Last Post: AKNL
  Writing list as a file, then reading that file as a list Zoastria_Balnala 3 2,594 Oct-17-2019, 07:54 PM
Last Post: Zoastria_Balnala

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020