Home > Mobile >  How do I write the whole word in cells?
How do I write the whole word in cells?

Time:12-14

I am trying to write data from json file to CSV file using python. My code is like this:

CSVFile1 = open('Group_A_participant_1_1.csv', 'a')
writeCSV1 = csv.writer(CSVFile1)

for file in data['annotations'][3]['instances']:
    var = file['arguments'].get('argument1')
    writeCSV1.writerow(var)
CSVFile.close()

My output is: enter image description here

So my problem is that I can not see the whole word in one cell.

Thanks your helps inn advance!

I expect to get each word in one single cell.

CodePudding user response:

Change

writeCSV1.writerow(var)

to

writeCSV1.writerow([var])

so you're writing an one-item list with your var instead of having the CSV module interpret var, a string, as separate characters.

CodePudding user response:

  1. Click on the first cell of the column where you want the converted names to appear (B2).
  2. Type equal sign (=), followed by the text “Prof. “, followed by an ampersand (&).
  3. Select the cell containing the first name (A2).
  4. Press the Return Key.
  5. You will notice that the title “Prof.” is added before the first name in the list.
  • Related