Python Forum
writing data from Amazon Workspaces to CSV
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
writing data from Amazon Workspaces to CSV
#1
Hello,

I'm trying to get my output from Amazon Workspaces to print to a file. I can get the data from workspaces, but I have not been able to write the data to the CSV file. I have been looking around the web, and all the answers I can find are the simplest possible answers, and only print the code from within Python itself. I can find no real-world examples that adequately address my problem. Any assistance is appreciated, Thank you.

This is my code:
import boto3
client = boto3.client('workspaces')
folder = input('directoryId> ')

workspaces = client.describe_workspaces()['Workspaces']
directoryIds = [workspaces['DirectoryId']for workspaces in workspaces]
directoryIds.sort()


for DirectoryIds in folder:
print(workspaces)



##----------------CSV Writer Code----------------##


import csv
with open('workspacesdata.csv', 'w', newline='') as csvfile:
datawriter = csv.writer(csvfile,dialect='excel')

fieldnames=['WorkspaceId', 'DirectoryId', 'UserName', 'IpAddress','State', 'BundleId', 'SubnetId','ComputerName','VolumeEncryptionKey' , 'WorkspaceProperties','RunningMode']
datawriter = csv.DictWriter(csvfile, fieldnames=fieldnames)
datawriter.writeheader()



##----------------CSV Reader Code----------------##

import os
os.system('start excel.exe workspacesdata.csv')
Yoriz write Sep-22-2022, 10:47 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
writing data from Amazon Workspaces to CSV - by isaac_python - Sep-22-2022, 10:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tools for writing and reading binary data in files Skaperen 0 1,474 Jun-08-2020, 07:28 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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