Populate CSV table with image name

Share your programming ideas for various measurement and analysis tasks here
Nick Davis
Posts: 8
Joined: Mon Jan 10, 2022 4:16 pm

Populate CSV table with image name

Post by Nick Davis »

How would I add the original file name to be populated in the outpu .CSV table that I am generating? Thank you

Code: Select all

    i8.SetChannelName(1,"Class 2")
    #i8.NameWithoutExtension = fileInfo.Name
#    Zen.Application.Documents.Add(i8) #<--- Add to gallery
    
    ##########################################
    #Create the metrics results
    ias= ZenImageAnalysisSetting(ZenAnalysisSettingType.ExternalMask) #<-- Using threshold i8 from above
    ias.Load("Binary")
    
    #Create the image analysis
    Zen.Analyzing.Analyze(i8,i8,ias) #<-- (Gray image, masked image, process)
    
    #Create the first table
    out= ZenTable()
    out= Zen.Analyzing.CreateRegionTable(i8,"Class 2")
    
    #Create the second table
    out1= ZenTable()
    out1= Zen.Analyzing.CreateRegionsTable(i8,"Classes 1")
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Populate CSV table with image name

Post by CarlZeissMicroscopy3 »

Hello Nick Davis,

I'm not sure if got you right but from my understanding you want to add a column 'filename' to the tables (out and out2) and write the filename of the image into it. Finaly the tables are saved as CSV.

In principle this can be done like this:

Code: Select all

myFileName = i8.NameWithoutExtension

table = ZenTable()
table.Columns.Add("filename",str)

for row in table.Rows:
    row["filename"] = myFileName
So in your case it would be

Code: Select all

myFileName = i8.NameWithoutExtension

#Create the first table
#out = ZenTable() <= not needed as CreateRegionTable gives back a ZenTable
out = Zen.Analyzing.CreateRegionTable(i8,"Class 2")

out.Columns.Add("filename",str)

for row in out.Rows:
    row["filename"] = myFileName
    
etc.
I hope this helps.
Nick Davis
Posts: 8
Joined: Mon Jan 10, 2022 4:16 pm

Re: Populate CSV table with image name

Post by Nick Davis »

Thank you. I shall try this soon.
herry lauu
Posts: 2
Joined: Tue Mar 07, 2023 8:30 am

Re: Populate CSV table with image name

Post by herry lauu »

You must also have the free version in order to utilize the Premium Addons Pro. You can dynamically link your tables to various resources on your website with Premium extensions.
stumble guys
Cody Walls
Posts: 4
Joined: Fri May 05, 2023 2:25 pm

Re: Populate CSV table with image name

Post by Cody Walls »

Because the csv module can only handle one row at a time, memory will not be an issue. The code below will concatenate the csv files, keeping only the first header and adding a filename column with the filename supplied.
jason bevis
Posts: 1
Joined: Thu Mar 30, 2023 10:08 am

Re: Populate CSV table with image name

Post by jason bevis »

In the rows below the column headers, enter the relevant Mini Crossword data. For example, in the "Image Name" column, you can enter the names of the images that you want to include.
silvana herrera
Posts: 1
Joined: Mon Jun 12, 2023 6:06 pm

Re: Populate CSV table with image name

Post by silvana herrera »

Thank you for the information. It has been very useful to me. I like the points regarding the placement of the
Mexico image and the various options that you can use with the codes.
linn ellaa
Posts: 2
Joined: Mon Feb 27, 2023 5:23 am

Re: Populate CSV table with image name

Post by linn ellaa »

In the first row of the CSV file, specify the column headers magic tiles 3. One of the column headers should be designated for the image names.
Rose J Lever
Posts: 23
Joined: Tue Jun 20, 2023 10:20 pm

Re: Populate CSV table with image name

Post by Rose J Lever »

To populate a CSV table with image names, you can use Python to iterate through the image files in a directory and write their names into a CSV file. By utilizing the os and csv modules, you can easily accomplish this task. First, you specify the directory where the images are stored. Then, you retrieve the list of image files in that directory. Next, you create a CSV file and write a header row to it. Finally, you iterate through the image files, writing each image name into a new row in the CSV file. This allows you to create a table with the image names in a CSV format for further analysis or processing. If anyone want to know about Garage door replacement Smithfield visit here
Rebecca Smith
Posts: 1
Joined: Fri Jul 14, 2023 11:44 pm

Re: Populate CSV table with image name

Post by Rebecca Smith »

okay this is totally helpful thankyou Kim Mulkey Purple Sequin Blazer
Post Reply