Encoding CSV File With arabic content
You need to convert your CSV file in UTF-8 or process your string using utf8_encode.
Make sure your MySQL table is also in UTF-8
CSV file with Arabic characters is displayed as symbols in Excel
This is a problem I face frequently with Microsoft Excel when opening CSV files that contain Arabic characters. Try the following workaround that I tested on latest versions of Microsoft Excel on both Windows and MacOS:
Open Excel on a blank workbook
Within the Data tab, click on From Text button (if not
activated, make sure an empty cell is selected)Browse and select the CSV file
In the Text Import Wizard, change the File_origin to "Unicode (UTF-8)"
Go next and from the Delimiters, select the delimiter used in your file e.g. comma
Finish and select where to import the data
The Arabic characters should show correctly.
How to open a CSV file in excel with arabic in it
- Rename File Extension with Arabic Character from .csv to txt say MS DOS.
- Here is the sample file
When you first save the File from csv to txt after renaming it, a pop up dialog will appear
3 Click cancel then a dialog box will appear
Save the txt file in Dir and rename to csv.
Here you will get choices for arabic characters.Arabic 708.720, 28596
- save the file and rename to txt, it opens with proper characters as shown below. But please ensure that , separation character is maintained, Some adjustment at line breaks and page may be required
How to a read CSV file that contains Arabic lines using Python
The python 2 csv
module doesn't handle unicode encodings well. The best solution is to start using python 3 which has integrated unicode and is well-suited for multi-language programming. If you need to stick with python 2, the unicodecsv
module (pip install unicodecsv
) is a drop-in replacement for csv
that handles non-ascii files.
# -*- coding: utf-8 -*-
import sys
try:
import unicodecsv as csv
except ImportError:
sys.stderr.write(
"`sudo pip install unicodecsv` for unicode csv support\n")
exit(1)
with open(u'testfile.csv', "rb") as csvfile:
reader = csv.reader(csvfile, encoding="utf-8-sig")
for row in reader:
print u", ". join(row)
Related Topics
How to Change Value of Select Options Based on Another Select Option Selected
Cross-Origin Request Headers(Cors) With PHP Headers
How to Get Time Difference in Minutes in PHP
Show a Number to Two Decimal Places
PHP - Ssl Certificate Error: Unable to Get Local Issuer Certificate
Laravel, Sync() - How to Sync an Array and Also Pass Additional Pivot Fields
Reference - Frequently Asked Questions About Pdo
How to Parameterize the Table Name in a Prepared Statement
Call to a Member Function on a Non-Object
Pdo Support For Multiple Queries (Pdo_MySQL, Pdo_MySQLnd)
Grabbing the Href Attribute of an a Element
Showing All Errors and Warnings
How to Create Cron Job Using PHP
How to Get a Youtube Video Thumbnail from the Youtube API
Replace Preg_Replace() E Modifier With Preg_Replace_Callback
How to Remove the Extra Square Bracket from Json Having Multiple Arrays