If you happen to be looking for something in java, you can try: https://github.com/deephaven/deephaven-csv
Benchmarks, along with other java alternatives discussed here: https://deephaven.io/blog/2022/02/23/csv-reader/
Actually, CSV is formalized in RFC 4180. Adherence to that spec is another story, of course. :-)
e.g. the Import Flat File wizard in SQL Server
Delimted File metadata tool in Talend
Basically they look at the first N rows and take a guess. If the guess turns out to be wrong its usually worse than not guessing at all.
In C# there's source generators.
I am sure there are other options for other languages.
If that's not correct or good enough, then a guessing is not a sufficient solution for this problem.