Any means of autoimporting CSV files into Calc?

No, for examlpe you can create csv-datasources in Base and import the result of (simple) queries directly to Calc.
.
And a simple macro does not need to be in an extension. I use several for exports. Imports I prefer to check myself…

The process to import what exactly? CSV is not a standardized file format.

Yes, you can write a simple macro and distribute it as an extension in order to import one specific flavor of csv. There are thousands of different flavors of csv out in the wild.

The most simple procedure is this:
Open one of your specific csv files specifying the right encoding, language, delimiters and extra options. Virtually everybody wants “detect special numbers”.
Next time you open the same flavor of csv, confirm the last import settings by hitting the Enter key.

Just a troll.

2 Likes

It’s clearly a problem with a solution as mentioned here.
.
I don’t understand why there’s so much resistance on this one particular issue for improving UX. If a file gets imported incorrectly on those edge cases they could just go through the dialogue.

Beause you are just a manipulative coin bro.

1 Like

I’m a capitalist. Are the LIbreoffice developers all opposed to capital markets? Are you some type of Communists, like Mozilla?
.
Literally, all cryptocurrency is is equity markets with a bunch of traditionally left wing jobs, in compliance and regulation, that introduce capital inefficiency, automated out of existence. Those jobs are replaced by computers. It literally let’s everyone with some savings play venture capitalist. It’s literally no different from the US equity markets, or any equity market. There are just as many scams as you find in regulated markets.
.
That’s not to mention the fact sending large amounts of money, and making large financial transactions have cheaper fees than tradfi. All of the financial markets are filled with fraud. It’s kind of the standard when dealing with money.

First. You are off topic. No more posts about unrelated stuff please, you are close to the line.
.
You are talking to users here, not developers.
.
You are welcome to use whatever office suite you like.
.
If it isn’t a high priority for most people (it isn’t) then you may pay someone to add the option of importing csv with the previous settings to LibreOffice.

I’m sorry.
.
I’m just surprised this entire topic gets responded with hostility by a vocal part of the userbase and developers. By looking over that bug report it looks like the topic causes flame wars. Sounds like it has something to do with region and language spoken for whether CSVs import easily or not. I just find it strange there’s a group so opposed to this when even the people believing the dialogue prompt is the right choice most likely have a general case that would work for most imports.
.
I understand it’s not a priority. I don’t even really need it since there’s a workaround. I just seems like an easy feature to add if anyone felt like it. It’s just a config file parser, and it looks like most of the code required to implement the feature is already there. I might do it myself if I have the time.

Some of the hostility comes from using Excel in a country that does not use USA type date formatting. In New Zealand, when Microsoft removed the text import dialogue, importing CSVs became an exercise in vigilance.
With date columns, Excel would convert anything that looked like a date to USA format where it could, the rest of the column was left as text in NZ date format causing damage to data as dates were wrongly created. Probably Excel has got better at reading locale from its own settings but I am not interested in buying it just to test that.
.
I had to create macros to import CSVs that were exported from our database to avoid such damage. You can create your own macro to import CSV if it is always the same layout. The book by Pitonyak is a good start for understanding LibreOffice macros, www.pitonyak.org/oo.php

2 Likes

In countries such as the US, UK and Australia, the default list separator is a comma, so you get CSV comma delimited. In non-English speaking European countries, a comma is reserved for the decimal symbol, and the list separator is generally set to semicolon. Based on this, your demand is quite unreasonable for the simple reason that at some point the translation has to be done anyway before the listing is printed on the screen or on paper. So now the question turns upside down: who are there more in the world, ordinary consumers or people working in the financial sector? And last but not least, who will end up footing the bill?

1 Like

While I can see the polarized opinions, I fail to see the stated “hostility by … developers”. Could you please point to the source of this specific part of your statement?

For my part, I see greed (even a bit of McCarthyism) in some of the opinions. Everything should be available to them for free. As far as I know, when running a business, for example, investments in software are tax deductible.
Well, it seems to be very common for deep rooted capitalists, for example, when they’re driving their luxury car and the road has potholes, they complain that nothing works, but at the same time they demand tax breaks and foremost see commies everywhere :wink:

OK, let’s dumb down further.
What is this: 123,456 :question:

Well, if you add a € sign after that, it’s just pocket money.
But if you add a $ sign in front of it, it’s quite big pocket money :wink:

Wrong. It’s 2 integers separated by a comma. :stuck_out_tongue:

1 Like

That was pretty good :woozy_face:

One trick, Microsoft used to play, is treating numeric strings as numbers. This way, you get different numeric values from the same text data, depending on Excel’s locale setting, while chances are pretty good that the dumb user does not take notice of wrongly imported data until he/she tries to SUM or sort these data.

Meanwhile, Calc submitted to this madness per default. A fresh profile reveals that ="1/2/34" + "1" yields either 1934-01-03 for the USA or 1934-02-02 for the bloody rest of the world.
This can be turned off via Tools>Options>Calc>Formula>Details… The strict setting (raise #VALUE!) lets you take notice of strange things going on in that sheet. The default is the same as Excel’s.
At least, LO allows adjusting this setting for individual documents.

A quick research about MS Excel, reveals that csv is properly imported when the numeric strings match with the locale setting. Same as Calc.
I could not find a single description about Excel importing non-matching data. I guess, that dumb user clicks [OK] anyway and happily imports text into the smart spreadsheet.
txt2num.ods (18.2 KB)

1 Like

3 lines from a bank statement of mine. Would be interesting to know, how a non-german Excel imports this stuff automatically:

27.01.2025;xxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxx-xxxxx;"xxxxxxxxxxxxxxxxxxxxxx; xxxxxxxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxx-xxxxx; xxxxxxxxxxx xxxxxxxx; ";"810,49";"2.429,06"
27.01.2025;xxx xx;"xxxxxxxxxxx xxxxxx; ; xxx xx; 311501; xxx: xxxxxxxx; xxxx: xx21512202000068660008";"-792,70";"41.618,57"
27.01.2025;"xxxxxx xxxxxxx xxxx xx xxx xxxxxxxx 20, 33333 xxxxxxxxx";"xxxx-xxxxxxxxxxxxxxxx; xxxxxx xxxxxxx xxxx xx xxx xxxxxxxx 20, 33333 xxxxxxxxx xxxxxxx; xxxxxxx xxx 200019; xxxxxxxx xx xx2299700000008303; xxx xx xxx xx: xxxxxxxxxxx xxxxxx-xxxxxxxx: xxxxxxxxxxx";"-94,61";"42.411,27"
23.01.2025;;"xxxxxxxxxxxxxxxxxxxxxx; xxxxxxxxxx xxx xxxxxxxxx xxxx; xx 2085799, xxxxxx, 20107511246; ";"45,66";"2.505,88"
1 Like

Would be funny if it just works. The W3C published standards for this ten years ago. Wonder if Microsoft and Google just need to pay one guy $100k to fix the problem. We’ll probably get AIs that can correct the errors before fixing a formatting error.

REM  *****  BASIC  *****

Sub ReadCSV()
	
	' This works if reading an EU .csv file and
	' writing the content to an en-US spreadsheet,
	' but it's not absolutely all-encompassing .
	
    GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
    Set FSO = CreateScriptService("FileSystem")
    Dim fullPath As String
    Dim folderPath As String
    Dim fullPathUrl As String
    
    Select Case OSName
        Case "WIN"
            folderPath = ConvertToURL(Environ("UserProfile") & "\Documents\CSV_files")
            fullPath = (Environ("UserProfile") & "\Documents\CSV_files\CSV_test.csv")            
        Case "LINUX", "OS2","UNIX","MAC"
            folderPath = ConvertToURL("/home/user/Documents/CSV_files")
            fullPath = folderPath & "/CSV_test.csv"
        Case Else
    End Select
    
    fullPathUrl = ConvertToURL(fullPath)
    
    If Not FSO.FolderExists(folderPath) Then
        MsgBox "Folder " & folderPath & " not found."
    End If

    Set FSO = Nothing
    Dim strContent As String

    strContent = ReadFromFile(fullPathUrl)

    If strContent = "" Then
    	If OSName = "WIN" Then
			MsgBox "File not found " & fullPath
		Else
			MsgBox "File not found " & fullPathUrl
		End If
		Exit Sub
    End If

    Dim  strSeparator As String
    
    IF InStr(strContent, ";") > 0 Then
    	strSeparator = ";"
    End If
    
    Dim isAllowed  As Boolean
	Dim oDoc As Object
	Dim oSheet As Object
	Dim oCell As Object
 	oDoc = ThisComponent
 	oSheet = ThisComponent.CurrentController.getActiveSheet()

	tempArray = Split(strContent, chr(13) & chr(10)) : strContent = "" 
	
	For i = Lbound(tempArray) To Ubound(tempArray)
	
		Dim temp2Array() As String 
		temp2Array() = Split(tempArray(i), strSeparator)
		 
		For j = Lbound(temp2Array) To Ubound(temp2Array)
			
			oCell = oSheet.getCellByPosition(j, i)
			isAllowed = True: doCnt = 32
			Do 
				doCnt = doCnt  + 1
				Select Case doCnt
					Case 33 To 42, 47, 58 To 126
						If InStr(temp2Array(j), chr(doCnt)) > 0 Then
							isAllowed = False : Exit Do
						End If
					Case Else
				End Select
			Loop Until doCnt =  126

			If strSeparator = ";" And IsAllowed Then
				If IsNumeric(Left(temp2Array(j), 1)) Then			
					temp2Array(j) = Replace(temp2Array(j), ",", ".")
					oCell.HoriJustify = com.sun.star.table.CellHoriJustify.RIGHT
				End If
			
				If IsNumeric(Left(temp2Array(j), 1))  And InStr(temp2Array(j), " ") > 0 Then
					temp2Array(j) = Replace(temp2Array(j), " ", ",")
				End If
			Else
				oCell.HoriJustify = com.sun.star.table.CellHoriJustify.LEFT	
			End If
		
			oCell.setString(temp2Array(j))
			
		Next j
		
		Erase temp2Arry()
		
	Next i
	
	Erase tempArray()
	
End Sub

Function ReadFromFile(sFileNameUrl As String) As String

    Dim FSO As Object
    
    GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
    Set FSO = CreateScriptService("FileSystem")
    
    If FSO.FileExists(sFileNameUrl) Then
        Dim inputFile As Object        
        Set inputFile = FSO.OpenTextFile(sFileNameUrl)
        ReadFromFile = inputFile.ReadAll()
        inputFile.CloseFile()
        Set FSO = Nothing
        Exit Function
    Else
        Set FSO = Nothing
        ReadFromFile = ""
    End If

End Function

Function OSName As String

    With GlobalScope.Basiclibraries
        If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
    End With

    Dim keyNode As Object
    keyNode = Tools.Misc.GetRegistryKeyContent("org.openoffice.Office.Common/Help")
    OSName = keyNode.GetByName("System")

End Function
1 Like