?
Solved

is csv file in ansi format

Posted on 2014-03-12
5
Medium Priority
?
1,597 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 2000 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

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
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…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
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…

764 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