Solved

is csv file in ansi format

Posted on 2014-03-12
5
1,483 Views
Last Modified: 2014-03-24
how can we know what format the csv flat file was saved as? ANSI or UNICODE or UTF-8?
0
Comment
Question by:25112
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39924524
Header. Look at the first bytes.

Unicode: FF FE
UTF8: EF BB BF

HTH,
Dan
0
 
LVL 5

Author Comment

by:25112
ID: 39926114
Dan, can you guide me how to find the header info. I used CSVed.exe, but i don't spot the header there..

thanks.
0
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39926212
Here's a simple PowerShell script to test the first bytes:
#test if a file is ASCII, Unicode or UTF-8 encoded
#Q_28386979 on E-E
$inputFile="X:\your\path\file.csv"

$encoding = "ASCII"
$firstBytes = get-content $inputFile -Encoding Byte -TotalCount 3

if ($firstBytes[0] -eq 239 -and $firstBytes[1] -eq 187 -and $firstBytes[2] -eq 191) {
    $encoding = "UTF-8"
} elseif ($firstBytes[0] -eq 255 -and $firstBytes[1] -eq 254) {
    $encoding = "Unicode"
}

echo $encoding

Open in new window

Replace "X:\your\path\file.csv" with your actual file.

The script will read the first 3 bytes from the file and output the encoding.

HTH,
Dan
0
 
LVL 5

Author Comment

by:25112
ID: 39952354
nice, thank you! :)
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39952361
Glad I could help!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question