export-to-csv

How to Convert HTML table to CSV file with same structure with powershell

淺唱寂寞╮ 提交于 2019-12-02 15:55:53
问题 With Powershell, I can get the table with this - $URL = "http://example.com/yyy.htm" $OutputFile = "$env:temp\tempfile.xml" # reading website data: $data = Invoke-WebRequest -Uri $URL # get the first table found on the website and write it to disk: @($data.ParsedHtml.getElementsByTagName("table"))[0].OuterHTML | Set-Content -Path $OutputFile Now I want this table to be converted to CSV... How do I do that? Table example - Datacenter | FirstDNS | SecondDNS | ThirdDNS | FourthDNS --------------

Fetching second row from csv file in Ruby [duplicate]

我怕爱的太早我们不能终老 提交于 2019-12-02 14:38:27
问题 This question already has answers here : Ignore header line when parsing CSV file (6 answers) Closed last year . actual_row = File.open(file_name[0], 'r') first_row_data = [] CSV.foreach(actual_row) do |row| first_row_data << row[1] end puts first_row_data With this I am trying to fetch the second row of CSV but it is printing the second column instead. 回答1: The foreach method returns an enumerator if no block is given, which allows you to use methods such as drop from Enumerable : # outputs

Create CSV File with PHP

放肆的年华 提交于 2019-12-02 13:19:04
I want to create a new .csv file (without opening the raw file first via fopen ). So far I have tried this: $list[] = array ( "Name" => "John" "Gender" => "M", "Age" => "21", ); $timestamp0 = date("Y-m-d H:i:sa",time()); $datetime = new DateTime($timestamp0); $datetime->setTimezone(new DateTimeZone('Asia/Jakarta')); $timestamp = $datetime->format("Y-m-d_H-i"); $filename = __DIR__ . "/file/" . $timestamp . ".csv"; $header = array ("name","gender","age"); file_put_contents($filename, implode ("\n", $list)); // error here bcs array given :') My questions are: How can I change array 2d to csv?

Output Data to CSV

旧巷老猫 提交于 2019-12-02 08:35:10
问题 Can someone please tell me how I can output data in a CSV format? I want to have it so that it clearly shows what users belong to what group: $site = Get-SPSite http://www.dev.com $groups = $site.RootWeb.sitegroups foreach ($grp in $groups) { "Group: " + $grp.name foreach ($user in $grp.users) { " User: " + $user.name } } $site.Dispose() 回答1: For exporting data to CSV use Export-Csv. Note, however, that Export-Csv exports the properties of objects as the CSV fields, so you have to prepare

Powershell variable export-CSV cache?

柔情痞子 提交于 2019-12-02 08:23:11
I am working on a script by Richard L. Mueller ( http://www.rlmueller.net/PowerShell/PSLastLogon.txt ) Trap {"Error: $_"; Break;} $D = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() $Domain = [ADSI]"LDAP://$D" $Searcher = New-Object System.DirectoryServices.DirectorySearcher $Searcher.PageSize = 200 $Searcher.SearchScope = "subtree" $Searcher.Filter = "(&(objectCategory=person)(objectClass=user))" $Searcher.PropertiesToLoad.Add("samAccountName") > $Null $Searcher.PropertiesToLoad.Add("lastLogon") > $Null $arrUsers = @{} ForEach ($DC In $D.DomainControllers) { $Server =

PHP export from MySQL into CSV

和自甴很熟 提交于 2019-12-02 07:46:15
问题 I need to export data from MySQL to CSV but from specific ID. Table contains ID, ParentID and Name and here is code which exports all records: <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "databasename"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $index = array(); $num = 0; $sql = "SELECT NAME, ID, PARENTID from

List physical drive space

我的梦境 提交于 2019-12-02 07:38:55
I have around 200 servers and I need to get the disk space & logical drive space details (free space, used space & total space). Here is my PowerShell query. $infoObjects = New-Object PSObject foreach ($machine in $servers) { $counts = Get-WmiObject -Query "SELECT * FROM Win32_DiskDrive" -ComputerName $machine $total_disk = @($counts).Count $i = 0 $total_disk = $total_disk -1 for (; $i -le $total_disk; $i++) { $a = $i $a = Get-WmiObject -Query "SELECT * FROM Win32_DiskDrive WHERE DeviceID='\\\\.\\PHYSICALDRIVE$i'" -ComputerName $machine $b = $i $b = [math]::round($a.size /1GB) Add-Member

jq: Object cannot be csv-formatted, only array

微笑、不失礼 提交于 2019-12-02 07:00:24
问题 I am new to jq and I have a JSON file from a DynamoDB table which I want to convert to CSV. This is my JSON file. [ { "SnsPublishTime": { "S": "2019-07-27T15:07:38.904Z" }, "SESreportingMTA": { "S": "dsn; a8-19.smtp-out.amazonses.com" }, "SESMessageType": { "S": "Bounce" }, "SESDestinationAddress": { "S": "bounce@simulator.amazonses.com" }, "SESMessageId": { "S": "0100016c33f91857-600a8e44-c419-4a02-bfd6-7f6908f5969e-000000" }, "SESbounceSummary": { "S": "[{\"emailAddress\":\"bounce@simulator

Export Sql data to .csv and generate separate .csv files per table based on query

夙愿已清 提交于 2019-12-02 05:48:47
Currently, I am using Go to access my database. Ideally, I'd like to generate .csv based on the table's name and export data to those files based on the query. For example, if I ran: select t1.*,t2.* from table1 t1 inner join table2 t2 on t2.table_1_id = t1.id where t1.linking_id = 22 I'd like a .csv file generated for both table 1 and table 2 where data from each table would generate and then export into these two generated files with the same names as the table's names. I know in PHP I can use $fp = fopen(getcwd().'/table1.csv', 'w'); fputcsv($fp, $columns); to generate the .csv files with

Python 3 - Read from & Write values to a .csv

假如想象 提交于 2019-12-02 03:25:49
问题 I am reading a .csv file, want to extract certain values from it and write these to a new result.csv (B) file. I tried doing this with the code (A), which is only partially working. In the definition i put all the variables from which i want to eventually extract the matching values out of the .csv file i am reading. (except for "record_id" and "abbreviation", because i will fill these manually) Now by running code (A), it generates the following output in the result.csv: Current output