Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
   I want to convert a incoming html file into csv/txt and I have a windows form through which i want to the insert that file's data into database(MYSQL).
The data will get inserted into the textboxes and then it will get inserted into table's column accordingly.
Also I'm actually scanning a ID's QR code from Android app through which on sharing I get the HTML data.
Is there anyway that it could fetch that file and then automatically import that file convert it and then import it or anything??

What should I do?
I have searched alot but not getting anything.
I want the latest text file to be inserted.


What I have tried:

1.I have successfully made a form that inserts data into database from the textboxes into the table columns.
2.I have written a powershell command that converts the html file into txt, it removes the html tags and delimits the data accordingly.
3.The powershell command exports the file with system date stamp.

The batch file command is something like this:

powershell -Command "(gc bluetooth_content_share.html) -replace '<[^>]+>', '' | Out-File bluetooth_content_share.txt"


powershell -Command "(gc bluetooth_content_share.txt) -replace 'Name : ', '' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'UID : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'Gender : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'Date of Birth : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'Street : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'Address : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'Village : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'District : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'State : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'Pincode : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) -replace 'City : ', ',' | Out-File bluetooth_content_share.txt"

powershell -Command "(gc bluetooth_content_share.txt) | Set-Content -Encoding utf8 bluetooth_content_share.txt


ren "bluetooth_content_share.txt" "bluetooth_content_share-%date:~10,4%%date:~7,2%%date:~4,2%-%time:~0,2%%time:~3,2%.txt"
Posted
Updated 14-Feb-18 22:57pm

1 solution

Not really. An HTML file is a page description, and a CSV file is a comma (and newline) separated list of values - there isn't any real overlap between the two formats so converting a generic HTML file to a list in any format isn't really going to work.

It's like trying to convert a wedding invitation to a shopping list: they aren't the same thing at all!

However, HTML data is text, so you could store it directly into a database (provided you pass it as a query parameter).

But I think you need to take a step back and think more clearly about exactly what you are trying to do - there are fundamental problems with this whole idea as described.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900