Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

CkPython Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Python) CSV Column Names

Demonstrates how to access CSV column names.

The Chilkat CSV library/component/class is freeware. The downloads for .NET, C++, Perl, Java, Ruby, and Python contain all of the Chilkat classes, some of which are freeware and some of which require licensing.

Chilkat Python Downloads

Python Module for Windows, Linux, Alpine Linux,
MAC OS X, Solaris, FreeBSD, OpenBSD,
Raspberry Pi and other single board computers

import sys
import chilkat

#  This example program loads a file (sample.csv)
#  that contains this content:
# 
#  year,color,country,food
#  2001,red,France,cheese
#  2005,blue,"United States",hamburger
#  2008,green,Italy,pasta
#  1998,orange,Japan,sushi
# 
#  The first row contains the column names.
#  This file is available at:
#  http://www.chilkatsoft.com/testData/sample.csv

csv = chilkat.CkCsv()

#  Prior to loading the CSV file, indicate that the 1st row
#  should be treated as column names:
csv.put_HasColumnNames(True)

#  Load the CSV records from the file:

success = csv.LoadFile("sample.csv")
if (success != True):
    print(csv.lastErrorText())
    sys.exit()

#  Display the column names:

for i in range(0,csv.get_NumColumns()):
    colName = csv.getColumnName(i)
    print(str(i) + ": " + colName)

    #  The following line demonstrates to to get the column
    #  index given a column name:
    idx = csv.GetIndex(colName)
    print(colName + " is at column index " + str(idx))


 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.